public void Update(Order order) { using (var db = new OrderDB()) { db.Order.Attach(order); db.Entry(order).State = EntityState.Modified; order.Items.ForEach(item => db.Entry(item).State = EntityState.Modified); db.SaveChanges(); } }
public void Add(Order order) { using (var db = new OrderDB()) { db.Entry(order).State = EntityState.Added; db.SaveChanges(); } }