views:

22

answers:

1

Hello

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 on the left hand side of += or -=

What is wrong?

/M

+2  A: 

You're calling the wrong method. SavingChanges is an event, not a method. You want SaveChanges, instead.

Craig Stuntz