本文介绍了批量更新/删除EF5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用(实体框架)EF5处理批量更新的最佳方法是什么?我有两个特殊情况我感兴趣的是:
-
更新一个列表(例如UpdateDate) (List)介于100到100.000之间的Id,这是主键。单独调用每个更新似乎是很大的开销,需要很长时间。
-
在100到100.000之间插入很多相同的对象(例如
任何好的建议?
解决方案
- 有两个开源项目允许这样做:和。您还可以查看关于EF Codeplex站点批量更新的。
- 插入100k通过EF记录首先是错误的应用程序架构。您应该为数据导入选择不同的轻量级技术。即使EF的内部操作与这样大的记录集将花费你很多处理时间。目前没有解决方案用于EF的批量插入,但是有关EF代码plex站点上的此功能的。 li>
What is the best way to deal with batch updates using (Entity Framework) EF5?I have 2 particular cases I'm interested in:
Updating a field (e.g. UpdateDate) for a list (List) of between 100 and 100.000 Id's, which the primary key. Calling each update separately seem to be to much overhead and takes a long time.
Inserting many, also between the 100 and 100.000, of the same objects (e.g. Users) in a single go.
Any good advice?
解决方案
- There are two open source projects allowing this: EntityFramework.Extended and Entity Framework Extensions. You can also check discussion about bulk updates on EF's codeplex site.
- Inserting 100k records through EF is in the first place wrong application architecture. You should choose different lightweight technology for data imports. Even EF's internal operation with such big record set will cost you a lot of processing time. There is currently no solution for batch inserts for EF but there is broad discussion about this feature on EF's code plex site.
这篇关于批量更新/删除EF5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!