Exemplo n.º 1
0
        private static void InsertCustomers()
        {
            using (var context = new OnlineStoreContext())
            {
                context.Customers.Add(new Customer()
                {
                    Name = "Sheva"
                });
                context.Add(new Customer()
                {
                    Name = "Albet"
                });
                context.AddRange(new[] { new Customer()
                                         {
                                             Name = "Masha"
                                         }, new Customer()
                                         {
                                             Name = "Dasha"
                                         } });

                context.SaveChanges();
                //Faster if you use bulkcopy(tempTable)
                //Console.WriteLine($"{customer.Name }{customer.Id }");
            }
        }
Exemplo n.º 2
0
 private static void InsertProducts()
 {
     using (var context = new OnlineStoreContext())
     {
         context.Add(new Product()
         {
             Name = "IPhone X", Price = 100
         });
         context.AddRange(new[] { new Product()
                                  {
                                      Name = "MacBook Pro", Price = 100
                                  }, new Product()
                                  {
                                      Name = "IWatch", Price = 200
                                  } });
         context.SaveChanges();
     }
 }