示例#1
0
 public override void CleanupTestDataSet()
 {
     using (var dataContext = new EF6Context()) {
         dataContext.Database.Connection.Open();
         dataContext.Entities.RemoveRange(dataContext.Entities.ToList());
         dataContext.SaveChanges();
     }
 }
示例#2
0
 public override void CreateTestDataSet(int recordsCount)
 {
     CleanupTestDataSet();
     EF6Entity[] data = new EF6Entity[recordsCount];
     for (int i = 0; i < recordsCount; i++)
     {
         data[i] = new EF6Entity()
         {
             Id = i, Value = i
         };
     }
     using (var dataContext = new EF6Context()) {
         dataContext.Database.Connection.Open();
         dataContext.Entities.AddRange(data);
         dataContext.SaveChanges();
     }
     RecordsCount = recordsCount;
 }
示例#3
0
 public override void InsertOne(int recordsCount)
 {
     using (var transaction = dataContext.Database.BeginTransaction()) {
         for (int i = 0; i < recordsCount; i++)
         {
             var item = new EF6Entity()
             {
                 Id = i, Value = i
             };
             dataContext.Entities.Add(item);
             dataContext.SaveChanges();
         }
         transaction.Commit();
     }
 }