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

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

问题描述

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

What is the best way to deal with batch updates using (Entity Framework) EF5? I have 2 particular cases I'm interested in:

  1. 为主键在 100 到 100.000 Id 之间的列表(List)更新字段(例如 UpdateDate).单独调用每个更新似乎开销很大并且需要很长时间.

  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.

一次性插入许多相同的对象(例如用户),也在 100 到 100.000 之间.

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

有什么好的建议吗?

推荐答案

  1. 有两个开源项目允许这样做:EntityFramework.Extended实体框架扩展.您还可以在 EF 的 codeplex 网站上查看关于批量更新的讨论.
  2. 通过 EF 插入 100k 记录首先是错误的应用程序架构.您应该为数据导入选择不同的轻量级技术.即使EF的内部操作有这么大的记录集,也会花费你大量的处理时间.目前没有针对 EF 批量插入的解决方案,但在 EF 的代码 plex 站点上有关于此功能的广泛讨论.莉>
  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天全站免登陆