コード例 #1
0
ファイル: Program.cs プロジェクト: singhk1988/presentations
 private static void RunAddAndSaveChangesOptimizedTest()
 {
     Console.WriteLine("Add 1K & SaveChanges (EF6 Optimized)");
     RunTest(
         () =>
     {
         using (var db = new PerformanceEf6.EF6.Context.AdventureWorksContext())
         {
             db.Configuration.AutoDetectChangesEnabled = false;
             var categories = new PerformanceEf6.EF6.Models.ProductCategory[1000];
             for (int i = 0; i < 1000; i++)
             {
                 categories[i] = new PerformanceEf6.EF6.Models.ProductCategory {
                     Name = $"Test {Guid.NewGuid()}"
                 };
             }
             db.ProductCategories.AddRange(categories);
             db.SaveChanges();
         }
     },
         () =>
     {
         using (var db = new PerformanceEfCore.EfStructures.Context.AdventureWorksContext())
         {
             for (int i = 0; i < 1000; i++)
             {
                 db.ProductCategories.Add(new PerformanceEfCore.EfStructures.Models.ProductCategory {
                     Name = $"Test {Guid.NewGuid()}"
                 });
             }
             db.SaveChanges();
         }
     });
 }
コード例 #2
0
ファイル: Program.cs プロジェクト: singhk1988/presentations
 private static void RunAddAndSaveChangesTest()
 {
     Console.WriteLine("Add 1K & SaveChanges");
     RunTest(
         TestEf6.AddRecordsAndSave,
         () =>
     {
         using (var db = new PerformanceEfCore.EfStructures.Context.AdventureWorksContext())
         {
             for (int i = 0; i < 1000; i++)
             {
                 db.ProductCategories.Add(new PerformanceEfCore.EfStructures.Models.ProductCategory {
                     Name = $"Test {Guid.NewGuid()}"
                 });
             }
             db.SaveChanges();
         }
     });
 }