public List <Order> SearchPriceMoreThan(double temp) { using (var db = new OrderDB()) { return(db.tb_Order.Include("Items").Where(m => m.TotalPrice >= temp).ToList <Order>()); } }
public List <Order> SearchOrderbyName(string temp) { using (var db = new OrderDB()) { return(db.tb_Order.Include("Items").Where(m => m.Name == temp).ToList <Order>()); } }
public List <Order> SearchAllOrders() { using (var db = new OrderDB()) { return(db.tb_Order.Include("Items").ToList <Order>()); } }
public void AddOrder(Order order) { using (var db = new OrderDB()) { db.tb_Order.Add(order); db.SaveChanges(); } }
public List <Order> SearchOrderbyItem(string temp) { using (var db = new OrderDB()) { var query = db.tb_Order.Include("Items").Where(m => m.Items.Where (n => n.Item == temp).Count() > 0); return(query.ToList <Order>()); } }
public void Update(Order order) { using (var db = new OrderDB()) { db.tb_Order.Attach(order); db.Entry(order).State = EntityState.Modified; order.Items.ForEach(item => db.Entry(item).State = EntityState.Modified); db.SaveChanges(); } }
public void DeleteByID(String id) { using (var db = new OrderDB()) { var order = db.tb_Order.Include("Items").SingleOrDefault(m => m.ID == id); db.tb_OrderDetails.RemoveRange(order.Items); //还需要删除 items 的内容 db.tb_Order.Remove(order); db.SaveChanges(); } }