Exemplo n.º 1
0
 public List <Order> GetAllOrders()
 {
     using (var db = new OrderDB())
     {
         return(db.Order.Include("Details").ToList <Order>());
     }
 }
Exemplo n.º 2
0
 public List <Order> QueryByCustormer(String custormer)
 {
     using (var db = new OrderDB())
     {
         return(db.Order.Include("Details")
                .Where(o => o.Customer.Equals(custormer)).ToList <Order>());
     }
 }
Exemplo n.º 3
0
 public Order GetOrder(String Id)
 {
     using (var db = new OrderDB())
     {
         return(db.Order.Include("Details").
                SingleOrDefault(o => o.Id == Id));
     }
 }
Exemplo n.º 4
0
 public List <Order> QueryByGoods(String product)
 {
     using (var db = new OrderDB())
     {
         var query = db.Order.Include("items")
                     .Where(o => o.Details.Where(
                                item => item.Product.Equals(product)).Count() > 0);
         return(query.ToList <Order>());
     }
 }
Exemplo n.º 5
0
 public void Delete(String orderId)
 {
     using (var db = new OrderDB())
     {
         var order = db.Order.Include("Details").SingleOrDefault(o => o.Id == orderId);
         db.OrderDetail.RemoveRange(order.Details);
         db.Order.Remove(order);
         db.SaveChanges();
     }
 }
Exemplo n.º 6
0
 public void Add(Order order)
 {
     using (var db = new OrderDB())
     {
         db.Order.Add(order);
         //db.Order.Attach(order);
         //db.Entry(order).State = EntityState.Added;
         db.SaveChanges();
     }
 }
Exemplo n.º 7
0
 public void Update(Order order)//修改
 {
     using (var db = new OrderDB())
     {
         db.Order.Attach(order);
         db.Entry(order).State = EntityState.Modified;
         order.Details.ForEach(
             item => db.Entry(item).State = EntityState.Modified);
         db.SaveChanges();
     }
 }