Example #1
0
 public void InsertNotInTransactionSpeed()
 {
     using (var context = new TestContext("Server=.;Initial Catalog=TestDb;Integrated security=True;"))
     {
         var sum = new Stopwatch();
         sum.Start();
         var sw = new Stopwatch();
         sw.Start();
         for (var i = 0; i < 100; i++)
         {
             var guid      = Guid.NewGuid();
             var newEntity = new ClassD
             {
                 EntityId          = guid,
                 Name              = "Lorem ipsum",
                 NumberOfSomething = 5
             };
             context.TestTable.Add(newEntity);
             Console.WriteLine("Add " + sw.Elapsed);
             sw.Restart();
             context.SaveChanges();
             Console.WriteLine("Persist " + sw.Elapsed);
             sw.Restart();
         }
         Console.WriteLine("-----");
         Console.WriteLine(sum.Elapsed);
     }
 }
Example #2
0
        public void WriteAndReadBack()
        {
            var sw = new Stopwatch();

            sw.Start();
            using (var context = new TestContext("Server=.;Initial Catalog=TestDb;Integrated security=True;"))
            {
                Console.WriteLine("Init " + sw.Elapsed);
                sw.Restart();

                var guid      = Guid.NewGuid();
                var newEntity = new ClassD
                {
                    EntityId          = guid,
                    Name              = "Lorem ipsum",
                    NumberOfSomething = 5
                };
                context.TestTable.Add(newEntity);
                Console.WriteLine("Add " + sw.Elapsed);
                sw.Restart();
                context.SaveChanges();
                Console.WriteLine("Persist " + sw.Elapsed);
                sw.Restart();

                var storedEntity = context.TestTable.SingleOrDefault(e => e.EntityId == guid);
                Console.WriteLine("Select " + sw.Elapsed);

                Assert.IsInstanceOfType(storedEntity, typeof(ClassD));

                var classD = (ClassD)storedEntity;
                Assert.AreEqual(classD.Name, newEntity.Name);
                Assert.AreEqual(classD.NumberOfSomething, newEntity.NumberOfSomething);
                Assert.AreNotEqual(classD.Id, 0);
            }
        }
Example #3
0
 public void ReadAll()
 {
     using (var context = new TestContext("Server=.;Initial Catalog=TestDb;Integrated security=True;"))
     {
         var sw = new Stopwatch();
         sw.Start();
         var entities = context.TestTable.ToList();
         Console.WriteLine("{0} Select {1}", entities.Count, sw.Elapsed);
     }
 }
Example #4
0
 public void Count()
 {
     using (var context = new TestContext("Server=.;Initial Catalog=TestDb;Integrated security=True;"))
     {
         var sw = new Stopwatch();
         sw.Start();
         var c = context.TestTable.Count();
         Console.WriteLine("Count {0}: {1}", c, sw.Elapsed);
     }
 }
Example #5
0
 private void X(int x)
 {
     using (var context = new TestContext("Server=.;Initial Catalog=TestDb;Integrated security=True;"))
     {
         var sw = new Stopwatch();
         sw.Start();
         var c = context.TestTable.Where(e => e.Id > x).ToList();
         Console.WriteLine("Count {0}: {1}", c.Count, sw.Elapsed);
     }
 }
Example #6
0
 public void SelectAndOr()
 {
     using (var context = new TestContext("Server=.;Initial Catalog=TestDb;Integrated security=True;"))
     {
         var sw = new Stopwatch();
         sw.Start();
         var c = context.TestTable.Where(e => e.Name == "Lorem ipsum" && (e.Id == 100 || e.Id == 200 || e.Id == 300)).ToList();
         Console.WriteLine("Count {0}: {1}", c.Count, sw.Elapsed);
     }
 }
Example #7
0
 public void SelectStringContains()
 {
     using (var context = new TestContext("Server=.;Initial Catalog=TestDb;Integrated security=True;"))
     {
         var sw = new Stopwatch();
         sw.Start();
         var c = context.TestTable.Where(e => e.Name.Contains("ipsum")).ToList();
         Console.WriteLine("Count {0}: {1}", c.Count, sw.Elapsed);
     }
 }
Example #8
0
 public void SelectOrderBy()
 {
     using (var context = new TestContext("Server=.;Initial Catalog=TestDb;Integrated security=True;"))
     {
         var sw = new Stopwatch();
         sw.Start();
         var c = context.TestTable.OrderByDescending(e => e.Id).ThenBy(e => e.Name).ToList();
         Console.WriteLine("Count {0}: {1}", c.Count, sw.Elapsed);
     }
 }
Example #9
0
 public void Update()
 {
     using (var context = new TestContext("Server=.;Initial Catalog=TestDb;Integrated security=True;"))
     {
         var sw = new Stopwatch();
         sw.Start();
         //context.TestTable.Where(e => e.Id == 1).Update();
         //Console.WriteLine("Count {0}: {1}", c.Count, sw.Elapsed);
     }
 }
Example #10
0
 public void GetTimePart()
 {
     using (var context = new TestContext("Server=.;Initial Catalog=TestDb;Integrated security=True;"))
     {
         var sw = new Stopwatch();
         sw.Start();
         var ts = new TimeSpan(10, 0, 0);
         var c  = context.TestTable.Count(e => e.Date.TimeOfDay > ts);
         Console.WriteLine("Count {0}: {1}", c, sw.Elapsed);
     }
 }
Example #11
0
 public void SelectContains()
 {
     using (var context = new TestContext("Server=.;Initial Catalog=TestDb;Integrated security=True;"))
     {
         var sw = new Stopwatch();
         sw.Start();
         var ids = new[] { 100, 200, 300, 400, 500 };
         var c   = context.TestTable.Where(e => ids.Contains(e.Id)).ToList();
         Console.WriteLine("Count {0}: {1}", c.Count, sw.Elapsed);
     }
 }
Example #12
0
 public void Count()
 {
     using (var context = new TestContext("Server=.;Initial Catalog=TestDb;Integrated security=True;"))
     {
         var sw = new Stopwatch();
         sw.Start();
         var c = context.TestTable.Count();
         Console.WriteLine("Count {0}: {1}", c, sw.Elapsed);
     }
 }
Example #13
0
 public void InsertNotInTransactionSpeed()
 {
     using (var context = new TestContext("Server=.;Initial Catalog=TestDb;Integrated security=True;"))
     {
         var sum = new Stopwatch();
         sum.Start();
         var sw = new Stopwatch();
         sw.Start();
         for (var i = 0; i < 100; i++)
         {
             var guid = Guid.NewGuid();
             var newEntity = new ClassD
             {
                 EntityId = guid,
                 Name = "Lorem ipsum",
                 NumberOfSomething = 5
             };
             context.TestTable.Add(newEntity);
             Console.WriteLine("Add " + sw.Elapsed);
             sw.Restart();
             context.SaveChanges();
             Console.WriteLine("Persist " + sw.Elapsed);
             sw.Restart();
         }
         Console.WriteLine("-----");
         Console.WriteLine(sum.Elapsed);
     }
 }
Example #14
0
 public void ReadAll()
 {
     using (var context = new TestContext("Server=.;Initial Catalog=TestDb;Integrated security=True;"))
     {
         var sw = new Stopwatch();
         sw.Start();
         var entities = context.TestTable.ToList();
         Console.WriteLine("{0} Select {1}", entities.Count, sw.Elapsed);
     }
 }
Example #15
0
 public void SelectAndOr()
 {
     using (var context = new TestContext("Server=.;Initial Catalog=TestDb;Integrated security=True;"))
     {
         var sw = new Stopwatch();
         sw.Start();
         var c = context.TestTable.Where(e => e.Name == "Lorem ipsum" && (e.Id == 100 || e.Id == 200 || e.Id == 300)).ToList();
         Console.WriteLine("Count {0}: {1}", c.Count, sw.Elapsed);
     }
 }
Example #16
0
 public void SelectContains()
 {
     using (var context = new TestContext("Server=.;Initial Catalog=TestDb;Integrated security=True;"))
     {
         var sw = new Stopwatch();
         sw.Start();
         var ids = new[] {100, 200, 300, 400, 500};
         var c = context.TestTable.Where(e => ids.Contains(e.Id)).ToList();
         Console.WriteLine("Count {0}: {1}", c.Count, sw.Elapsed);
     }
 }
Example #17
0
 public void SelectOrderBy()
 {
     using (var context = new TestContext("Server=.;Initial Catalog=TestDb;Integrated security=True;"))
     {
         var sw = new Stopwatch();
         sw.Start();
         var c = context.TestTable.OrderByDescending(e => e.Id).ThenBy(e => e.Name).ToList();
         Console.WriteLine("Count {0}: {1}", c.Count, sw.Elapsed);
     }
 }
Example #18
0
 public void SelectStringContains()
 {
     using (var context = new TestContext("Server=.;Initial Catalog=TestDb;Integrated security=True;"))
     {
         var sw = new Stopwatch();
         sw.Start();
         var c = context.TestTable.Where(e => e.Name.Contains("ipsum")).ToList();
         Console.WriteLine("Count {0}: {1}", c.Count, sw.Elapsed);
     }
 }
Example #19
0
 public void Update()
 {
     using (var context = new TestContext("Server=.;Initial Catalog=TestDb;Integrated security=True;"))
     {
         var sw = new Stopwatch();
         sw.Start();
         //context.TestTable.Where(e => e.Id == 1).Update();
         //Console.WriteLine("Count {0}: {1}", c.Count, sw.Elapsed);
     }
 }
Example #20
0
        public void WriteAndReadBack()
        {
            var sw = new Stopwatch();
            sw.Start();
            using (var context = new TestContext("Server=.;Initial Catalog=TestDb;Integrated security=True;"))
            {
                Console.WriteLine("Init " + sw.Elapsed);
                sw.Restart();

                var guid = Guid.NewGuid();
                var newEntity = new ClassD
                {
                    EntityId = guid,
                    Name = "Lorem ipsum",
                    NumberOfSomething = 5
                };
                context.TestTable.Add(newEntity);
                Console.WriteLine("Add " + sw.Elapsed);
                sw.Restart();
                context.SaveChanges();
                Console.WriteLine("Persist " + sw.Elapsed);
                sw.Restart();

                var storedEntity = context.TestTable.SingleOrDefault(e => e.EntityId == guid);
                Console.WriteLine("Select " + sw.Elapsed);

                Assert.IsInstanceOfType(storedEntity, typeof(ClassD));

                var classD = (ClassD) storedEntity;
                Assert.AreEqual(classD.Name, newEntity.Name);
                Assert.AreEqual(classD.NumberOfSomething, newEntity.NumberOfSomething);
                Assert.AreNotEqual(classD.Id, 0);
            }
        }
Example #21
0
 public void GetTimePart()
 {
     using (var context = new TestContext("Server=.;Initial Catalog=TestDb;Integrated security=True;"))
     {
         var sw = new Stopwatch();
         sw.Start();
         var ts = new TimeSpan(10, 0, 0);
         var c = context.TestTable.Count(e => e.Date.TimeOfDay > ts);
         Console.WriteLine("Count {0}: {1}", c, sw.Elapsed);
     }
 }
Example #22
0
 private void X(int x)
 {
     using (var context = new TestContext("Server=.;Initial Catalog=TestDb;Integrated security=True;"))
     {
         var sw = new Stopwatch();
         sw.Start();
         var c = context.TestTable.Where(e => e.Id > x).ToList();
         Console.WriteLine("Count {0}: {1}", c.Count, sw.Elapsed);
     }
 }