Ejemplo n.º 1
0
 private static void EfPure(Context ct, Stopwatch efsw)
 {
     efsw.Start();
     for (var i = 0; i < 1000; i++)
     {
         var item = new Item()
             {
                 City = 1,
                 CoreID = Guid.NewGuid(),
                 Name = "more that one time"
             };
         ct.Items.Add(item);
         ct.SaveChanges();
     }
     efsw.Stop();
     Console.WriteLine("Pure EF 1000 record time {0}", efsw.ElapsedMilliseconds);
 }
Ejemplo n.º 2
0
        private static void EfOffBatch(Context ct, Stopwatch efsw)
        {
            var list = new List<Item>();
            for (var i = 0; i < 1000; i++)
            {
                var item = new Item()
                {
                    City = 1,
                    CoreID = Guid.NewGuid(),
                    Name = "more that one time"
                };

                list.Add(item);
            }
            ct.Configuration.AutoDetectChangesEnabled = false;
            efsw.Restart();
            ct.Items.AddRange(list);
            ct.SaveChanges();
            efsw.Stop();
            Console.WriteLine("Off detect batch EF 1000 record time {0}", efsw.ElapsedMilliseconds);
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            var efsw = new Stopwatch();
            var efbatch = new Stopwatch();

            var ct = new Context();

            EfPure(ct, efsw);
            EfBatch(ct, efsw);
            EfOff(ct, efsw);
            EfOffBatch(ct, efsw);
            PureSql(efsw);
            SqlSp(efsw);
            Console.ReadLine();
        }