示例#1
0
        private static void InsertOrder()
        {
            var order = new Order
            {
                Cost = 100,
                CustomerId = 1
            };

            using (var db = new SaleContext())
            {
                db.Orders.Add(order);
                db.SaveChanges();
            }
        }
示例#2
0
        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();
            }
        }
示例#3
0
        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();
            }
        }