public static IEnumerable<Customer> GetAllCustomersWithOrderMadeIn1997ShipedToCanadaSQL() { string sqlQuery = "SELECT DISTINCT c.CompanyName FROM dbo.Customers c INNER JOIN dbo.Orders o ON o.CustomerID = c.CustomerID WHERE o.OrderDate BETWEEN '1997-01-01 00:00:00' AND '1998-01-01 00:00:00' AND o.ShipCountry = 'Canada'"; NorthwindEntities context = new NorthwindEntities(); var result = context.Database.SqlQuery<Customer>(sqlQuery); return result; }
public void Insert(Customer entity) { this.context.Customers.Add(entity); this.context.SaveChanges(); disposeCounte++; if (disposeCounte % 100 == 0) { disposeCounte = 0; this.context.Dispose(); this.context = new NorthwindEntities(); } }
public CustomerRepository() { this.context = new NorthwindEntities(); this.disposeCounte = 0; }