Entity Framework Batch Update
NuGet Package
PM> Install-Package EntityFramework.Extended
- NuGet: http://nuget.org/List/Packages/EntityFramework.Extended
- Source: http://github.com/loresoft/EntityFramework.Extended
Batch Update and Delete
A current limitations of the Entity Framework is that in order to update or delete an entity you have to first retrieve it into memory. Now in most scenarios this is just fine. There are however some senerios where performance would suffer. Also, for single deletes, the object must be retrieved before it can be deleted requiring two calls to the database. Batch update and delete eliminates the need to retrieve and load an entity before modifying it.
Deleting
//delete all users where FirstName matches
context.Users.Delete(u => u.FirstName == "firstname");
Update
//update all tasks with status of 1 to status of 2
context.Tasks.Update(
t => t.StatusId == 1,
t => new Task {StatusId = 2}); //example of using an IQueryable as the filter for the update
var users = context.Users
.Where(u => u.FirstName == "firstname"); context.Users.Update(
users,
u => new User {FirstName = "newfirstname"});
Oringinal Link:http://weblogs.asp.net/pwelter34/entity-framework-batch-update-and-future-queries
Entity Framework Batch Update的更多相关文章
- 第四篇 Entity Framework Plus 之 Batch Operations
用 Entity Framework 进行 增,删,改.都是基于Model进行的,且Model都是有状态追踪的.这样Entity Framework才能正常增,删,改. 有时候,要根据某个字段,批量 ...
- Entity Framework Tutorial Basics(27):Update Entity Graph
Update Entity Graph using DbContext: Updating an entity graph in disconnected scenario is a complex ...
- 采用EntityFramework.Extended 对EF进行扩展(Entity Framework 延伸系列2)
前言 Entity Framework 延伸系列目录 今天我们来讲讲EntityFramework.Extended 首先科普一下这个EntityFramework.Extended是什么,如下: 这 ...
- 第一篇 Entity Framework Plus 之 Audit
一般系统会有登陆日志,操作日志,异常日志,已经满足大部分的需求了.但是有时候,还是需要Audit 审计日志,审计日志,主要针对数据增,改,删操作数据变化的记录,主要是对数据变化的一个追踪过程.其中主要 ...
- Batch update returned unexpected row count from update [0] 异常处理
在one-to-many时遇到此异常,本以为是配置出错.在使用s标签开启debug模式,并在struts2主配置文件中添加异常映射,再次提交表单后得到以下异常详情. org.springframewo ...
- [转]How to Improve Entity Framework Add Performance?
本文转自:http://entityframework.net/improve-ef-add-performance When you overuse the Add() method for mul ...
- Entity Framework Plus
ZZZ Project 这家外国公司,有很多关于.NET和数据访问的项目,有收费的,有开源的,我之前介绍过 Z.ExtensionMethods 一个强大的开源扩展库 就出自该名下,其他有 如下 1. ...
- [转]Upgrading to Async with Entity Framework, MVC, OData AsyncEntitySetController, Kendo UI, Glimpse & Generic Unit of Work Repository Framework v2.0
本文转自:http://www.tuicool.com/articles/BBVr6z Thanks to everyone for allowing us to give back to the . ...
- Entity Framework 6 vs NHibernate 4
This article is dedicated to discussing the latest releases of the NHibernate and Entity Framework. ...
随机推荐
- dojo demo, server验证username是否已经被使用
这个demo有助于理解JS与server的协同工作. 文档结构如上图. 主要是三个文件: main.js table.html validateUserName.jsp (代码见文章末尾) 页面打 ...
- HDU 1757 A Simple Math Problem(矩阵高速幂)
题目地址:HDU 1757 最终会构造矩阵了.事实上也不难,仅仅怪自己笨..= =! f(x) = a0 * f(x-1) + a1 * f(x-2) + a2 * f(x-3) + -- + a9 ...
- 爱加密亮相第十八届软博会,移动App安全引关注
2014年5月29日至31日,2014年第十八届中国国际软件博览会在北京展览馆举行,此次软博会的主题为"软件引领信息消费,助力经济转型升级",充分展示软件业在促进信息消费.提升社会 ...
- ASP.NET之自定义异步HTTP处理程序(图文教程)
前面我们学习了关于关于自定义同步HTTP处理程序,相信大家可能感觉有所成就,但是这种同步的机制只能对付客户访问较少的情况或者数据处理量不大的情况,而今天这篇文章就是解决同步HTTP处理程序的这个致命缺 ...
- .NET程序性能优化基本要领
想了解更多关于新的编译器的信息,可以访问 .NET Compiler Platform ("Roslyn") 基本要领 在对.NET 进行性能调优以及开发具有良好响应性的应 ...
- js正则判断电话/手机/邮箱/
用途:校验ip地址的格式 输入:strIP:ip地址返回:如果通过验证返回true,否则返回false:*/ function isIP(strIP) { if (isNull(strIP)) ret ...
- UINavigationController和UITabBarController合用
一.创建一个 Tabbed Application.默认创建的是带有两个Tab的工程. 二.在AppDelegate.h里面添加 @property (strong, nonatomic) UINav ...
- C语言预处理指令
C程序的源代码中可包括各种编译指令,这些指令称为预处理命令.虽然它们实际上不是C语言的一部分,但却扩展了C程序设计的环境.本节将介绍如何应用预处理程序和注释简化程序开发过程,并提高程序的可读性.ANS ...
- 5.7.13mysql 无法登陆
话不多说 用的http://dev.mysql.com/downloads/mysql/下的ZIP Archive安装方式 下载 解压,然后吧bin目录添加到系统path环境变量下.然后将my-de ...
- C# 1作业 2广场砖面积 护栏长度
作业1输入圆柱体的底面半径和高求体积 static void Main(string[] args) { //输入圆柱体的底面半径, ...