public void Add(Order order) { using (var dataContext = new DataContext()) { dataContext.Set<Order>().Add(order); dataContext.SaveChanges(); } }
public void Delete(Guid orderId) { using (var dataContext = new DataContext()) { var order = dataContext.Set<Order>().Find(orderId); dataContext.Entry(order).State = EntityState.Deleted; dataContext.SaveChanges(); } }
public Order Get(Guid id) { using (var dataContext = new DataContext()) { return dataContext .Set<Order>() .Include("Lines") .FirstOrDefault(x => x.Id == id); } }