コード例 #1
0
 public List <Order> GetAllOrders()
 {
     using (var db = new orderDB())
     {
         return(db.Order.Include("details").ToList <Order>());
     }
 }
コード例 #2
0
 public List <Order> QueryByCustormer(String custormer)
 {
     using (var db = new orderDB())
     {
         return(db.Order.Include("details")
                .Where(o => o.custumerName.Equals(custormer)).ToList <Order>());
     }
 }
コード例 #3
0
 public Order GetOrder(String Id)
 {
     using (var db = new orderDB())
     {
         return(db.Order.Include("details").
                SingleOrDefault(o => o.Id == Id));
     }
 }
コード例 #4
0
 public void Add(Order order)
 {
     using (var db = new orderDB())
     {
         db.Order.Add(order);
         db.SaveChanges();
     }
 }
コード例 #5
0
 public List <Order> QueryByAmountMoney(double money)
 {
     using (var db = new orderDB())
     {
         var query = db.Order.Include("details")
                     .Where(o => o.Details.Where(
                                item => item.AmountMoney > money).Count() > 0);
         return(query.ToList <Order>());
     }
 }
コード例 #6
0
 public List <Order> QueryByGoods(String product)
 {
     using (var db = new orderDB())
     {
         var query = db.Order.Include("details")
                     .Where(o => o.Details.Where(
                                item => item.GoodsName.Equals(product)).Count() > 0);
         return(query.ToList <Order>());
     }
 }
コード例 #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();
     }
 }
コード例 #8
0
        public void Delete(String orderId)
        {
            using (var db = new orderDB())
            {
                var order = db.Order.Include("details").SingleOrDefault(o => o.Id == orderId);
                db.OrderDetails.RemoveRange(order.Details);

                db.Order.Remove(order);

                db.SaveChanges();
            }
        }