How to update only one field using Entity Framework
var tableEmployee = new T_Employees() { EmployeeID = item.EmployeeID , IsDisplayRequired = item.IsDisRequired
};
using (var db = new DBEntitiesContext())
{
db.Configuration. ValidateOnSaveEnabled = false;
db.T_Employees.Attach(tableEmployee) ;
db.Entry(tableEmployee) .Property(x => x.IsDisplayRequired). IsModified = true;
db.SaveChanges();
db.Configuration. ValidateOnSaveEnabled = true;
}
0 comments:
Post a Comment