关于C#批量增删改操作,大数据优化

用到是一个叫EF扩展Z.EntityFrameWork类


dbContext.Configuration.AutoDetectChangesEnabled =false;// 解决批量性能问题 

List machines = new List() ; //对象集合

for(inti =0; i < bedNoList.Count; i++) 

 { 

            EFModel.Machine machine = CreateMachine(bedNoList[i],true); 

             machines.Add(machine); 

 } 

dbContext.BulkInsert(machines);//插入

dbContext.BulkDelete(machines);//删除

 dbContext.BulkSaveChanges();


你可能感兴趣的:(关于C#批量增删改操作,大数据优化)