SaveChanges(): "...can only appear on the left hand..."
I have this piece of code:
Schedule chk = _entities.Schedules.Where(x => x.ScheduleStart == schedule.ScheduleStart && x.ScheduleEnd <= schedule.ScheduleEnd).FirstOrDefault();
if (chk != null)
{
chk.Discontinued = true;
_entities.SavingChanges();
}
basically if something exists in database with that criteria, set discontinued = true and save...
but I get this error:
The event 'System.Data.Objects.ObjectContext.SavingChanges' can only appear 开发者_如何学Goon the left hand side of += or -=
What is wrong?
/M
You're calling the wrong method. SavingChanges
is an event, not a method. You want SaveChanges
, instead.
精彩评论