static void Listing21_13() { Console.WriteLine("{0} : Begin", new StackTrace(0, true).GetFrame(0).GetMethod().Name); NorthwindEntities context = new NorthwindEntities(); // create a new customer object Customer cust = Customer.CreateCustomer("LAWN", "Lawn Wranglers"); // populate the remaining fields cust.ContactName = "Mr. Abe Henry"; cust.ContactTitle = "Owner"; cust.Address = "1017 Maple Leaf Way"; cust.City = "Ft. Worth"; cust.Region = "TX"; cust.PostalCode = "76104"; cust.Country = "USA"; cust.Phone = "(800) MOW-LAWN"; cust.Fax = "(800) MOW-LAWO"; context.AddObject("Customers", cust); context.SaveChanges(); Console.WriteLine("{0} : End", new StackTrace(0, true).GetFrame(0).GetMethod().Name); }
public virtual void Create(T entity) { _context.AddObject(this.EntitySetName, entity); _context.SaveChanges(); }