Exemplo n.º 1
0
 private static void RunComplexQueryTest()
 {
     Console.WriteLine("Query Complex");
     RunTest(
         ef6Test: () =>
         {
             using (var db = new EF6.AdventureWorksContext())
             {
                 db.Customers
                     .Where(c => !c.AccountNumber.EndsWith("1"))
                     .OrderBy(c => c.AccountNumber)
                     .ThenBy(c => c.ModifiedDate)
                     .Skip(100)
                     .GroupBy(c => c.TerritoryID)
                     .ToList();
             }
         },
         ef7Test: () =>
         {
             using (var db = new EFCore.AdventureWorksContext())
             {
                 db.Customers
                     .Where(c => !c.AccountNumber.EndsWith("1"))
                     .OrderBy(c => c.AccountNumber)
                     .ThenBy(c => c.ModifiedDate)
                     .Skip(100)
                     .GroupBy(c => c.TerritoryID)
                     .ToList();
             }
         });
 }
Exemplo n.º 2
0
        private static void ResetAndWarmup()
        {
            using (var db = new EF6.AdventureWorksContext())
            {
                db.Database.ExecuteSqlCommand(@"DELETE FROM Production.ProductCategory WHERE Name LIKE 'Test %'");
                db.Customers.FirstOrDefault();
            }

            using (var db = new EFCore.AdventureWorksContext())
            {
                db.Customers.FirstOrDefault();
            }
        }
Exemplo n.º 3
0
 private static void RunToListTest()
 {
     Console.WriteLine("Query ToList");
     RunTest(
         ef6Test: () =>
         {
             using (var db = new EF6.AdventureWorksContext())
             {
                 db.Customers.ToList();
             }
         },
         ef7Test: () =>
         {
             using (var db = new EFCore.AdventureWorksContext())
             {
                 db.Customers.ToList();
             }
         });
 }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            ResetAndWarmup();

            RunTest(
                ef6Test: () =>
                {
                    using (var db = new EF6.AdventureWorksContext())
                    {
                        
                    }
                },
                efCoreTest: () =>
                {
                    using (var db = new EFCore.AdventureWorksContext())
                    {
                        
                    }
                });
        }
Exemplo n.º 5
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();
             }
         });
 }
Exemplo n.º 6
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();
             }
         });
 }