public static void addCustomer() { using (var db = new NORTHWNDEntities()) { Customer cus = new Customer { Address = "suThep", CompanyName = "No", City = "ChiangMai", ContactName = "ChiangMai", ContactTitle = "Title", Country = "ChiangMai", CustomerID = "1111", Fax = "053", Phone = "222", PostalCode = "111", Region = "000" }; db.Customers.Add(cus); db.SaveChanges(); } Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name.ToString()); }
public static void deleteCustomer() { using (var db = new NORTHWNDEntities()) { var cus = db.Customers.Where(c => c.CustomerID == "1111").FirstOrDefault(); if (cus != null) { db.Customers.Remove(cus); db.SaveChanges(); } } Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name.ToString()); }
public static void updateCustomer() { using (var db = new NORTHWNDEntities()) { var cus = db.Customers.Where(c => c.CustomerID == "1111").FirstOrDefault(); if (cus != null) { cus.Fax = "093-236"; cus.Phone = "0932635"; db.SaveChanges(); } } Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name.ToString()); }