I have a many-to-many relationship between Department
objects and Grade
objects, I am trying to update the Department
by assigning a Grade
. This is my update method:
public void UpdateDep(CommonLayer.Depratment UpDep)
{
CommonLayer.Depratment CheckDepartment = this.getDepartment(UpDep.Department_GUID);
this.Entities.Entry(CheckDepartment).CurrentValues.SetValues(UpDep);
this.Entities.SaveChanges();
}
UpDep
has the Grade
id value but CheckDepartment
is not being updated. No errors are being shown. I cannot understand what is wrong, as I have done this many times before.
Why not?
public void UpdateDep(CommonLayer.Depratment UpDep)
{
CommonLayer.Depratment CheckDepartment = this.getDepartment(UpDep.Department_GUID);
this.Entities.Entry(CheckDepartment).CurrentValues.SetValues(UpDep);
this.Entities.Entry(CheckDepartment).State = EntityState.Changed;
this.Entities.SaveChanges();
}
notice the state.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.