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. ...
随机推荐
- Python with ASP
Python with ASP Python with ASP
- javascript设计模式——Publish/Subscribe
推荐阅读http://dev.housetrip.com/2014/09/15/decoupling-javascript-apps-using-pub-sub-pattern/ 我们先引出问题的所在 ...
- 根据树父子ID拼接无限极树结构表的名称
declare @c varchar(50)set @c='572a3d51-ef7a-459e-a5cd-ebf0fca51e8b' --能查出来呀 你试试,我试一下,好像可以啦谢谢 declare ...
- Oracle 归档路径
Oracle 的归档路径设置,这里主要按照官网说明记录 LOG_ARCHIVE_DEST_n 与 LOG_ARCHIVE_DEST_STATE_n 这两个参数. 我使用的数据库是11.2版本,这两个参 ...
- L10 PUtty+SSH 访问vncviewer
在Linux下配置一个VNC服务器,并设置2个用户,要求其中一个用户登录时不需要输入密码.然后在客户端使用ssh+vncview的方式访问. 安装tigervnc: 输入的密码是123456 连接服务 ...
- static 和 extern
外部函数:定义的函数能被本文件和其他文件访问,默认所有的情况都是外部函数,不允许有同名的外部函数 >>extern定义和声明一个外部函数(可以省略) 内部函数:定义的函数只能被本文件访问, ...
- HTML 5 JavaScript初步 编译运行.doc
编译运行 解释运行 JavaScript:只有一种变量类型,var.数据类型:整型,小数,字符串,布尔型 1.如何把数值型字符串变成数字型: parseInt("字符串")——把字 ...
- thoughtworks家庭作业C++版本
商品类: #ifndef ITEM_H_ #define ITEM_H_ class SalesTax; //This represents the Items which don't have an ...
- Servlet 浅谈(三)
关于Session 关于http协议后面会有一系列文章专门介绍.这里就大概了解一下:首先需要知道一点:HTTP是无状态的. 什么是无状态呢? 客户与服务器建立连接.发出请求.得到响应.关闭连接.整个流 ...
- sublime前端编辑器入门与个人使用经验分享
Sublime Text(以下简称sublime)是一款很好用的代码编辑器,小巧且很灵敏,几乎可以编写大部分主流的计算机语言代码,更是堪称前端代码编辑神器. 你百度一下会发现许多sublime的安装和 ...