Example #1
0
 private static void RunAddAndSaveChangesTest()
 {
     Console.WriteLine("Add & SaveChanges");
     RunTest(
         () =>
     {
         using (var db = new EF6.AdventureWorksContext())
         {
             for (int i = 0; i < 1000; i++)
             {
                 db.ProductCategories.Add(new EF6.ProductCategory {
                     Name = $"Test {Guid.NewGuid()}"
                 });
             }
             db.SaveChanges();
         }
     },
         () =>
     {
         using (var db = new EFCore.AdventureWorksContext())
         {
             for (int i = 0; i < 1000; i++)
             {
                 db.ProductCategories.Add(new EFCore.ProductCategory {
                     Name = $"Test {Guid.NewGuid()}"
                 });
             }
             db.SaveChanges();
         }
     });
 }
Example #2
0
 private static void RunAddAndSaveChangesTest()
 {
     Console.WriteLine("Add & SaveChanges");
     RunTest(
         () =>
         {
             using (var db = new EF6.AdventureWorksContext())
             {
                 for (int i = 0; i < 1000; i++)
                 {
                     db.ProductCategories.Add(new EF6.ProductCategory { Name = $"Test {Guid.NewGuid()}" });
                 }
                 db.SaveChanges();
             }
         },
         () =>
         {
             using (var db = new EFCore.AdventureWorksContext())
             {
                 for (int i = 0; i < 1000; i++)
                 {
                     db.ProductCategories.Add(new EFCore.ProductCategory { Name = $"Test {Guid.NewGuid()}" });
                 }
                 db.SaveChanges();
             }
         });
 }
Example #3
0
 private static void RunAddAndSaveChangesOptimizedTest()
 {
     Console.WriteLine("Add & SaveChanges (EF6 Optimized)");
     RunTest(
         () =>
     {
         using (var db = new EF6.AdventureWorksContext())
         {
             db.Configuration.AutoDetectChangesEnabled = false;
             var categories = new EF6.ProductCategory[1000];
             for (int i = 0; i < 1000; i++)
             {
                 categories[i] = new EF6.ProductCategory {
                     Name = $"Test {Guid.NewGuid()}"
                 };
             }
             db.ProductCategories.AddRange(categories);
             db.SaveChanges();
         }
     },
         () =>
     {
         using (var db = new EFCore.AdventureWorksContext())
         {
             for (int i = 0; i < 1000; i++)
             {
                 db.ProductCategories.Add(new EFCore.ProductCategory {
                     Name = $"Test {Guid.NewGuid()}"
                 });
             }
             db.SaveChanges();
         }
     });
 }
Example #4
0
 private static void RunAddAndSaveChangesOptimizedTest()
 {
     Console.WriteLine("Add & SaveChanges (EF6 Optimized)");
     RunTest(
         () =>
         {
             using (var db = new EF6.AdventureWorksContext())
             {
                 db.Configuration.AutoDetectChangesEnabled = false;
                 var categories = new EF6.ProductCategory[1000];
                 for (int i = 0; i < 1000; i++)
                 {
                     categories[i] = new EF6.ProductCategory { Name = $"Test {Guid.NewGuid()}" };
                 }
                 db.ProductCategories.AddRange(categories);
                 db.SaveChanges();
             }
         },
         () =>
         {
             using (var db = new EFCore.AdventureWorksContext())
             {
                 for (int i = 0; i < 1000; i++)
                 {
                     db.ProductCategories.Add(new EFCore.ProductCategory { Name = $"Test {Guid.NewGuid()}" });
                 }
                 db.SaveChanges();
             }
         });
 }