美文网首页
关于C#批量增删改操作,大数据优化

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

作者: 简猿 | 来源:发表于2018-04-03 15:29 被阅读0次

用到是一个叫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#批量增删改操作,大数据优化

      本文链接:https://www.haomeiwen.com/subject/njeycftx.html