コード例 #1
0
 static public void AddOrder(Order order)
 {
     using (var dataBase = new OrdersDB())
     {
         dataBase.orders.Add(order);
         dataBase.SaveChanges();
     }
 }
コード例 #2
0
 static public void DeletOrder(Order order)
 {
     using (var dataBase = new OrdersDB())
     {
         var tempOrder = dataBase.orders.Include("products").SingleOrDefault(temp => temp.num.Equals(order.num));
         dataBase.products.RemoveRange(tempOrder.products);
         dataBase.orders.Remove(tempOrder);
         dataBase.SaveChanges();
     }
 }
コード例 #3
0
 static public void ChangeOrder(Order order)
 {
     using (var dataBase = new OrdersDB())
     {
         dataBase.orders.Attach(order);
         dataBase.Entry(order).State = EntityState.Modified;
         order.products.ForEach
             (product => dataBase.Entry(product).State = EntityState.Modified);
         dataBase.SaveChanges();
     }
 }