예제 #1
0
        private static void BulkInsert()
        {
            using (EntitiesModel context = new EntitiesModel())
            {
                List<Product> productsNew = new List<Product>();
                for (int i = 0; i < 1000; i++)
                {
                    productsNew.Add(new Product() { Discontinued = false, ProductName = "Product" + i });
                }

                context.Add(productsNew);
                context.SaveChanges();
            }
        }
예제 #2
0
        private static TimeSpan SlowDelete()
        {
            using (EntitiesModel context = new EntitiesModel())
            {
                Stopwatch watch = new Stopwatch();

                var customersToRemove = from product in context.Products
                                        where (product.ProductID > 80)
                                        select product;

                watch.Start();
                context.Delete(customersToRemove);
                //context.Delete(context.Products.Where(p => p.ProductID % 7 == 2 && p.ProductID > 80));
                context.SaveChanges();
                watch.Stop();

                return watch.Elapsed;
            }
        }