public void ReviseOrder(Order order) { using (var db = new OrderDB()) { db.Order.Attach(order); db.Entry(order).State = EntityState.Modified; order.oDlist.ForEach( item => db.Entry(item).State = EntityState.Modified); db.SaveChanges(); } }
public void AddOrder(Order order) { using (var db = new OrderDB()) { db.Order.Add(order); db.Order.Attach(order); db.Entry(order).State = EntityState.Added; db.SaveChanges(); } Console.WriteLine("添加成功"); }