开发者

SaveChanges(): "...can only appear on the left hand..."

开发者 https://www.devze.com 2022-12-13 10:26 出处:网络
I have this piece of code: Schedule chk = _entities.Schedules.Where(x => x.ScheduleStart == schedule.ScheduleStart && x.ScheduleEnd <= schedule.ScheduleEnd).FirstOrDefault();

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消