public void SpecialEvents_Delete(SpecialEvent item) { using (eRestaurantContext context = new eRestaurantContext()) { // Lookup the instance and record if found SpecialEvent existing = context.SpecialEvents.Find(item.EventCode); // Setup the command to execute the delete context.SpecialEvents.Remove(existing); //command is not executed until it is actually saved. context.SaveChanges(); } }
public void SpecialEvents_Update(SpecialEvent item) { using (eRestaurantContext context = new eRestaurantContext()) { // Indicate the updating item instance // alter the Modified Status flag for this instance context.Entry<SpecialEvent>(context.SpecialEvents.Attach(item)).State = System.Data.Entity.EntityState.Modified; // command is not executed until it is actually saved. context.SaveChanges(); } }
public void SpecialEvents_ADD(SpecialEvent item) { using (eRestaurantContext context = new eRestaurantContext()) { /* These methods are executed using an instance level item * set up a instance pointer and initialize to null */ SpecialEvent added = null; // setup the command to execute the add added = context.SpecialEvents.Add(item); // command is not executed until it is actually saved. context.SaveChanges(); } }