private static void InsertOrder() { var order = new Order { Cost = 100, CustomerId = 1 }; using (var db = new SaleContext()) { db.Orders.Add(order); db.SaveChanges(); } }
private static void InsertOrders() { var orders = new List<Order> { new Order { CustomerId = 1, Cost = 200}, new Order { CustomerId = 1, Cost = 300} }; using (var db = new SaleContext()) { db.Orders.AddRange(orders); db.SaveChanges(); } }
private static void InsertCustomer() { var customer = new Customer { Name = "Tony", DateOfBirth = DateTime.Now, Id = 1 }; using (var db = new SaleContext()) { db.Customers.Add(customer); db.SaveChanges(); } }