private static void BulkDelete(EntitiesModel context)
        {
            context.Log = null;

            var query = context.GetAll<Product>().Where(p => p.ProductID % 7 == 1);
            int deleted = query.DeleteAll();

            Console.WriteLine("Deleted products: {0}", deleted);
        }
        private static MemoryStream SerializeToBinaryStream(string customerId)
        {
            BinaryFormatter formatter = new BinaryFormatter();

            MemoryStream stream = new MemoryStream();
            using (EntitiesModel dbContext = new EntitiesModel())
            {
                Customer customer = dbContext.Customers.Where(c => c.CustomerID == customerId).First();
                formatter.Serialize(stream, customer);
            }

            return stream;
        }
        private static void BulkInsert(EntitiesModel context)
        {
            List<Product> products = new List<Product>(50000);

            for (int i = 0; i < 50000; i++)
            {
                Product product = new Product() { ProductName = "Lexus" + i, SupplierID = 5, CategoryID = 5, UnitPrice = 1000m, QuantityPerUnit = "1 piece" };
                products.Add(product);
            }

            context.Add(products);

            context.SaveChanges();
        }
        private static void TestOpenAccessDelete()
        {
            var context = new EntitiesModel();

            try
            {
                var products = context.Products.Count();

                Console.WriteLine(products);
            }
            catch (Exception e)
            {

                Console.WriteLine(e.InnerException);
            }

            // Use this to populate your database with 50000 products
            BulkInsert(context);

            //BulkDelete(context);

            //SlowDelete(context);

        }
 private static void SlowDelete(EntitiesModel context)
 {
     context.Delete(context.Products.Where(p => p.ProductID % 7 == 2));
     context.SaveChanges();
 }