批量更新/删除EF5 [英] Batch update/delete EF5

查看:170
本文介绍了批量更新/删除EF5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用(实体框架)EF5处理批量更新的最佳方法是什么?
我有两个特殊情况我感兴趣的是:


  1. 更新一个列表(例如UpdateDate) (List)介于100到100.000之间的Id,这是主键。单独调用每个更新似乎是很大的开销,需要很长时间。


  2. 在100到100.000之间插入很多相同的对象(例如


任何好的建议?

解决方案


  1. 有两个开源项目允许这样做: EntityFramework .Extended 实体框架扩展程序。您还可以查看关于EF Codeplex站点批量更新的讨论

  2. 插入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:

  1. 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.

  2. Inserting many, also between the 100 and 100.000, of the same objects (e.g. Users) in a single go.

Any good advice?

解决方案

  1. 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.
  2. 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆