Example #1
0
 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 EfCore.Context.AdventureWorksContext())
         {
             for (int i = 0; i < 1000; i++)
             {
                 db.ProductCategories.Add(new EfCore.Models.ProductCategory {
                     Name = $"Test {Guid.NewGuid()}"
                 });
             }
             db.SaveChanges();
         }
     });
 }
Example #2
0
        private static void ResetAndWarmup()
        {
            TestEf6.ResetAndWarmUp();

            using (var db = new EfCore.Context.AdventureWorksContext())
            {
                //db.Database.ExecuteSqlCommand(@"DELETE FROM Production.ProductCategory WHERE Name LIKE 'Test %'");
                db.Customers.FirstOrDefault();
            }
        }
Example #3
0
 private static void RunToListTestQueryType()
 {
     Console.WriteLine("Query 19K ToList Query Type");
     RunTest(
         ef6Test: TestEf6.GetAllCustomers,
         ef7Test: () =>
     {
         using (var db = new EfCore.Context
                         .AdventureWorksContext())
         {
             db.CustomersQuery.ToList();
         }
     });
 }
Example #4
0
 private static void RunToListTestUntracked()
 {
     Console.WriteLine("Query 19K ToList UnTracked");
     RunTest(
         ef6Test: TestEf6.GetAllCustomers,
         ef7Test: () =>
     {
         using (var db = new EfCore.Context
                         .AdventureWorksContext())
         {
             db.Customers.AsNoTracking().ToList();
         }
     });
 }
Example #5
0
 private static void RunComplexQueryTest()
 {
     Console.WriteLine("Query Complex");
     RunTest(
         ef6Test: TestEf6.RunComplexQuery,
         ef7Test: () =>
     {
         using (var db = new EfCore.Context.AdventureWorksContext())
         {
             var el = EfCore.Repo.GetComplexData(db);
             //var el = Repo.CompiledQuery(db).ToList();
             //var el = Repo.GetComplexDataQueryType(db).ToList();
         }
     });
 }
Example #6
0
 private static void RunAddAndSaveChangesTest()
 {
     Console.WriteLine("Add 1K & SaveChanges");
     RunTest(
         TestEf6.AddRecordsAndSave,
         () =>
     {
         using (var db = new EfCore.Context.AdventureWorksContext())
         {
             for (int i = 0; i < 1000; i++)
             {
                 db.ProductCategories.Add(new EfCore.Models.ProductCategory {
                     Name = $"Test {Guid.NewGuid()}"
                 });
             }
             db.SaveChanges();
         }
     });
 }
Example #7
0
 private static void RunComplexQueryTestCorevsCore()
 {
     Console.WriteLine("Query Complex Core vs Core");
     RunTest(
         ef6Test: () =>
     {
         using (var db = new EfCore.Context.AdventureWorksContext())
         {
             var el = EfCore.Repo.GetComplexData(db);
         }
     },
         ef7Test: () =>
     {
         using (var db = new EfCore.Context.AdventureWorksContext())
         {
             //var el = Repo.CompiledQuery(db).ToList();
             var el = EfCore.Repo.GetComplexDataQueryType(db).ToList();
         }
     },
         firstLabel: "-  FromSQL",
         secondLabel: "- Compiled");
 }
Example #8
0
 private static void RunToListTestCoreVsQueryTypeAsView()
 {
     Console.WriteLine("Query 19K ToList Query Type vs QueryType From View");
     RunTest(
         ef6Test: () =>
     {
         using (var db = new EfCore.Context
                         .AdventureWorksContext())
         {
             db.CustomersQuery.ToList();
         }
     },
         ef7Test: () =>
     {
         using (var db = new EfCore.Context
                         .AdventureWorksContext())
         {
             db.CustomersView.ToList();
         }
     },
         firstLabel: "-  QueryType",
         secondLabel: "- QueryTypeAsView");
 }
Example #9
0
 private static void RunToListTestCoreVsQueryType()
 {
     Console.WriteLine("Query 19K ToList UnTracked vs QueryType");
     RunTest(
         ef6Test: () =>
     {
         using (var db = new EfCore.Context
                         .AdventureWorksContext())
         {
             db.Customers.AsNoTracking().ToList();
         }
     },
         ef7Test: () =>
     {
         using (var db = new EfCore.Context
                         .AdventureWorksContext())
         {
             db.CustomersQuery.ToList();
         }
     },
         firstLabel: "-  Untracked",
         secondLabel: "- QueryType");
 }