protected override void Dispose(bool disposing) { if (disposing) { db.Dispose(); } base.Dispose(disposing); }
public int OrderCount() { NorthwindDemoEntities entities = new NorthwindDemoEntities(); int orderCount = entities.Orders.Count(); entities.Dispose(); return(orderCount); }
public List <string> LastNOrders(int id) { NorthwindDemoEntities entities = new NorthwindDemoEntities(); int numberOfOrdersToReturn = id; List <Orders> lastOrders = (from o in entities.Orders orderby o.OrderDate descending select o).Take(numberOfOrdersToReturn).ToList(); List <string> customerNames = lastOrders.Select(o => o.Customers.CompanyName).ToList(); entities.Dispose(); return(customerNames); }