Пример #1
0
 public void Test_1_BlockInsertWithSession() {
     Stopwatch watch = new Stopwatch();
     watch.Start();
     using (var session = sessionFactory.OpenSession()) {
         for (int i = 0; i < InsertCount; i++) {
             var data = new TestData {
                 Id = Guid.NewGuid().ToString(),
                 Name = "Test Data " + i,
                 Data1 = random.Next(),
                 Data2 = random.Next(),
                 Data3 = random.NextDouble(),
                 UpdateTime = DateTime.Now
             };
             session.Save(data);
         }
         session.Flush();
         session.Clear();
     }
     watch.Stop();
     Console.WriteLine("MySqlBatchTest Test_1_BlockInsertWithSession: " + watch.Elapsed);
 }
Пример #2
0
 public void Test_2_BlockInsertWithStatelessSession() {
     using (var session = sessionFactory.OpenStatelessSession()) {
         session.SetBatchSize(1);
         for (int i = 0; i < InsertCount; i++) {
             var data = new TestData {
                 Id = Guid.NewGuid().ToString(),
                 Name = "Test Data " + i,
                 Data1 = random.Next(),
                 Data2 = random.Next(),
                 Data3 = random.NextDouble(),
                 UpdateTime = DateTime.Now
             };
             session.Insert(data);
         }
     }
 }