Exemplo n.º 1
0
 //删除订单
 public void RemoveOrder(long ordernumber)
 {
     using (var db = new OrderDB())
     {
         var order = db.Order.Include("orderDetails").SingleOrDefault(o => o.orderNumber == ordernumber);
         db.OrderDetail.RemoveRange(order.orderDetail);
         db.Order.Remove(order);
         db.SaveChanges();
     }
     //orderDictionary.Remove(ordernumber);
 }
Exemplo n.º 2
0
 public void Update(Order order)
 {
     using (var db = new OrderDB())
     {
         db.Order.Attach(order);
         db.Entry(order).State = EntityState.Modified;
         order.orderDetail.ForEach(
             item => db.Entry(item).State = EntityState.Modified);
         db.SaveChanges();
     }
 }
Exemplo n.º 3
0
 //添加订单
 public void AddOrder(Order order)
 {
     using (var db = new OrderDB())
     {
         db.Order.Add(order);
         db.SaveChanges();
     }
     //if (orderDictionary.ContainsKey(order.orderNumber))
     //    throw new Exception("Order has existed.");
     //orderDictionary[order.orderNumber] = order;
 }