I have Entity Framework Repository Dal (EFRepositoryDAL.cs) And I wrote this code for Update Records.
public void UpdateItem(T item)
{
using (WindowsaDairContext ent = new WindowsaDairContext())
{
ent.Set<T>().Attach(item);
ent.Entry<T>(item).State = System.Data.EntityState.Modified;
ent.SaveChanges();
}
}
And I have a model class like this.
public int UserDetailID { get; set; }
public Nullable<int> UserId { get; set; }
public bool Sex { get; set; }
public Nullable<byte> CityID { get; set; }
public Nullable<byte> EducationStatusID { get; set; }
public Nullable<DateTime> Birthday { get; set; }
public string UserIP { get; set; }
public Nullable<bool> Online { get; set; }
public string About { get; set; }
public string ProfilePicture { get; set; }
public Nullable<byte> PrestigePoint { get; set; }
But I want to update not all of fields with this repository class. Like I want to update only, "About","Profile Picture" fields. I want, the other fields can not change. But the other fields set NULL value. How can I solve this problem? Thanks.