當前位置: 首頁>>代碼示例>>C#>>正文


C# RestaurantContext.SaveChanges方法代碼示例

本文整理匯總了C#中eRestaurant.DAL.RestaurantContext.SaveChanges方法的典型用法代碼示例。如果您正苦於以下問題:C# RestaurantContext.SaveChanges方法的具體用法?C# RestaurantContext.SaveChanges怎麽用?C# RestaurantContext.SaveChanges使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在eRestaurant.DAL.RestaurantContext的用法示例。


在下文中一共展示了RestaurantContext.SaveChanges方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: AddTable

 public int AddTable(Table item)
 {
     using (RestaurantContext context = new RestaurantContext())
     {
         var added = context.Tables.Add(item);
         context.SaveChanges();
         return added.TableID;
     }
 }
開發者ID:rsxlancer,項目名稱:DMIT2018-In-Class,代碼行數:9,代碼來源:RestaurantAdminController.cs

示例2: DeleteSpecialEvent

 public void DeleteSpecialEvent(SpecialEvent item)
 {
     using (RestaurantContext context = new RestaurantContext())
     {
         var existing = context.SpecialEvents.Find(item.EventCode);
         context.SpecialEvents.Remove(existing);
         context.SaveChanges();
     }
 }
開發者ID:Eirikson,項目名稱:In-Class-A02,代碼行數:9,代碼來源:RestaurantAdminController.cs

示例3: AddSpecialEvent

 public void AddSpecialEvent(SpecialEvent item)
 {
     using (RestaurantContext context = new RestaurantContext())
     {
         // TODO: Validation rules...
         var added = context.SpecialEvents.Add(item);
         context.SaveChanges();
     }
 }
開發者ID:Eirikson,項目名稱:In-Class-A02,代碼行數:9,代碼來源:RestaurantAdminController.cs

示例4: DeleteItem

 public void DeleteItem(Item item)
 {
     using (RestaurantContext context = new RestaurantContext())
     {
         var existing = context.Items.Find(item.ItemID);
         context.Items.Remove(existing);
         context.SaveChanges();
     }
 }
開發者ID:Eirikson,項目名稱:In-Class-A02,代碼行數:9,代碼來源:RestaurantAdminController.cs

示例5: DeleteWaiter

 public void DeleteWaiter(Waiter item)
 {
     using (RestaurantContext context = new RestaurantContext())
     {
         var existing = context.Waiters.Find(item.WaiterID);
         context.Waiters.Remove(existing);
         context.SaveChanges();
     }
 }
開發者ID:Bbyrne6,項目名稱:In-Class,代碼行數:9,代碼來源:RestaurantAdminController.cs

示例6: AddItem

 public int AddItem(Item item)
 {
     using (RestaurantContext context = new RestaurantContext())
     {
         // TODO: Validation rules...
         var added = context.Items.Add(item);
         context.SaveChanges();
         return added.ItemID;
     }
 }
開發者ID:Eirikson,項目名稱:In-Class-A02,代碼行數:10,代碼來源:RestaurantAdminController.cs

示例7: UpdateWaiter

 public void UpdateWaiter(Waiters item)
 {
     using (RestaurantContext context = new RestaurantContext())
     {
         var attached = context.Waiters.Attach(item);
         var existing = context.Entry<Waiters>(attached);
         existing.State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
開發者ID:tciarroni,項目名稱:eRestaurant-Sample,代碼行數:10,代碼來源:RestaurantAdminController.cs

示例8: AddWaiter

 public int AddWaiter(Waiter item)
 {
     using (RestaurantContext context = new RestaurantContext())
     {
         // TODO: Validation rules...
         var added = context.Waiters.Add(item);
         context.SaveChanges();
         return added.WaiterID;
     }
 }
開發者ID:Bbyrne6,項目名稱:In-Class,代碼行數:10,代碼來源:RestaurantAdminController.cs

示例9: UpdateWaiter

 public void UpdateWaiter(Waiter item)
 {        
     using (RestaurantContext context = new RestaurantContext())
     {
         //TODO: Validation
         var attached = context.Waiters.Attach(item);
         var matchingWithExistingValues = context.Entry<Waiter>(attached);
         matchingWithExistingValues.State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
開發者ID:mmayo2,項目名稱:DMIT2018InClass,代碼行數:11,代碼來源:RestaurantAdminController.cs

示例10: UpdateTable

 public void UpdateTable(Table item)
 {
     using (RestaurantContext context = new RestaurantContext())
     {
         //TODO: Validation...
         var attached = context.Tables.Attach(item);
         var existing = context.Entry<Table>(attached);
         existing.State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
開發者ID:punq,項目名稱:DMIT2018inclass,代碼行數:11,代碼來源:RestaurantAdminController.cs

示例11: DeleteTable

 public void DeleteTable(Table item)
 {
     using (RestaurantContext context = new RestaurantContext())
     {
         var existing = context.Tables.Find(item.TableID);
         context.Tables.Remove(existing);
         context.SaveChanges();
     }
 }
開發者ID:mmayo2,項目名稱:DMIT2018InClass,代碼行數:9,代碼來源:RestaurantAdminController.cs

示例12: UpdateTable

 public void UpdateTable(Table item)
 {
     using (RestaurantContext context = new RestaurantContext())
     {
         var attached = context.Tables.Attach(item);
         var matchingWithExistedValues = context.Entry<Table>(attached);
         matchingWithExistedValues.State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
開發者ID:rsxlancer,項目名稱:DMIT2018-In-Class,代碼行數:10,代碼來源:RestaurantAdminController.cs

示例13: DeleteReservation

 public void DeleteReservation(Reservation item)
 {
     using (RestaurantContext context = new RestaurantContext())
     {
         var existing = context.Reservations.Find(item.EventCode);
         context.Reservations.Remove(existing);
         context.SaveChanges();
     }
 }
開發者ID:mklause1,項目名稱:DMIT2018-In-Class,代碼行數:9,代碼來源:RestaurantAdminController.cs

示例14: AddEvent

 public string AddEvent(SpecialEvent item)
 {
     using (RestaurantContext context = new RestaurantContext())
     {
         //TODO: Validation of waiter data...
         var added = context.SpecialEvents.Add(item);
         context.SaveChanges();
         return added.EventCode;
     }
 }
開發者ID:rsxlancer,項目名稱:DMIT2018-In-Class,代碼行數:10,代碼來源:RestaurantAdminController.cs

示例15: AddReservation

 public void AddReservation(Reservation item)
 {
     using (RestaurantContext context = new RestaurantContext())
     {
         var added = context.Reservations.Add(item);
         context.SaveChanges();
     }
 }
開發者ID:mklause1,項目名稱:DMIT2018-In-Class,代碼行數:8,代碼來源:RestaurantAdminController.cs


注:本文中的eRestaurant.DAL.RestaurantContext.SaveChanges方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。