static void Delete(string customerID) { var db = new northwindEntities(); using (db) { var customerToDelete = db.Customers.Find(customerID); db.Customers.Remove(customerToDelete); db.SaveChanges(); } }
static void Delete(string customerID) { var db = new northwindEntities(); using (db) { var customerToDelete = db.Customers.Find(customerID); db.Customers.Remove(customerToDelete); db.SaveChanges(); } }
static void Edit(string customerID, string companyName, string city, string country) { var db = new northwindEntities(); using (db) { var customerToEdt = db.Customers.Find(customerID); customerToEdt.CompanyName = companyName; customerToEdt.City = city; customerToEdt.Country = country; db.SaveChanges(); } }
static void Edit(string customerID, string companyName, string city, string country) { var db = new northwindEntities(); using (db) { var customerToEdt = db.Customers.Find(customerID); customerToEdt.CompanyName = companyName; customerToEdt.City = city; customerToEdt.Country = country; db.SaveChanges(); } }
static void Add(string customerID, string companyName, string city, string country) { var db = new northwindEntities(); using(db) { var customer = new Customer() { CustomerID = customerID, CompanyName = companyName, City = city, Country = country }; db.Customers.Add(customer); db.SaveChanges(); } }
static void Add(string customerID, string companyName, string city, string country) { var db = new northwindEntities(); using (db) { var customer = new Customer() { CustomerID = customerID, CompanyName = companyName, City = city, Country = country }; db.Customers.Add(customer); db.SaveChanges(); } }
static void FindSalesByDateRange(string region, DateTime startDate, DateTime endDate) { var db = new northwindEntities(); using (db) { var sales = db.Orders .Where(x => x.ShipRegion == region && x.OrderDate > startDate && x.OrderDate < endDate) .Select(x => new { ShipDate = x.ShippedDate, Region = x.ShipRegion }); db.SaveChanges(); foreach (var sale in sales) { Console.WriteLine("Ship date " + sale.ShipDate + " Ship Region " + sale.Region); } } }
static void FindSalesByDateRange(string region, DateTime startDate, DateTime endDate) { var db = new northwindEntities(); using (db) { var sales = db.Orders .Where(x => x.ShipRegion == region && x.OrderDate > startDate && x.OrderDate < endDate) .Select(x => new { ShipDate = x.ShippedDate, Region = x.ShipRegion }); db.SaveChanges(); foreach (var sale in sales) { Console.WriteLine("Ship date " + sale.ShipDate + " Ship Region " + sale.Region); } } }