NuGet Package

PM> Install-Package 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的更多相关文章

  1. 第四篇 Entity Framework Plus 之 Batch Operations

    用 Entity Framework  进行 增,删,改.都是基于Model进行的,且Model都是有状态追踪的.这样Entity Framework才能正常增,删,改. 有时候,要根据某个字段,批量 ...

  2. Entity Framework Tutorial Basics(27):Update Entity Graph

    Update Entity Graph using DbContext: Updating an entity graph in disconnected scenario is a complex ...

  3. 采用EntityFramework.Extended 对EF进行扩展(Entity Framework 延伸系列2)

    前言 Entity Framework 延伸系列目录 今天我们来讲讲EntityFramework.Extended 首先科普一下这个EntityFramework.Extended是什么,如下: 这 ...

  4. 第一篇 Entity Framework Plus 之 Audit

    一般系统会有登陆日志,操作日志,异常日志,已经满足大部分的需求了.但是有时候,还是需要Audit 审计日志,审计日志,主要针对数据增,改,删操作数据变化的记录,主要是对数据变化的一个追踪过程.其中主要 ...

  5. Batch update returned unexpected row count from update [0] 异常处理

    在one-to-many时遇到此异常,本以为是配置出错.在使用s标签开启debug模式,并在struts2主配置文件中添加异常映射,再次提交表单后得到以下异常详情. org.springframewo ...

  6. [转]How to Improve Entity Framework Add Performance?

    本文转自:http://entityframework.net/improve-ef-add-performance When you overuse the Add() method for mul ...

  7. Entity Framework Plus

    ZZZ Project 这家外国公司,有很多关于.NET和数据访问的项目,有收费的,有开源的,我之前介绍过 Z.ExtensionMethods 一个强大的开源扩展库 就出自该名下,其他有 如下 1. ...

  8. [转]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 . ...

  9. Entity Framework 6 vs NHibernate 4

    This article is dedicated to discussing the latest releases of the NHibernate and Entity Framework. ...

随机推荐

  1. javascript第十三课:Json

    js中的json就是字典,Dictionary,就是字典的简化创建方式,json的遍历使用for in的方式,进行遍历 遍历复杂json格式 (如果数组里面存储的是键值对的话,字符串最好用双引号) v ...

  2. SNMP协议具体解释

    简单网络管理协议(SNMP)是TCP/IP协议簇的一个应用层协议.在1988年被制定,并被Internet体系结构委员会(IAB)採纳作为一个短期的网络管理解决方式:因为SNMP的简单性,在Inter ...

  3. 用户名_密码获取Access_Token

    http://www.ivanjevremovic.in.rs/live/domination/red/index-async-slider.html http://designova.net/rev ...

  4. 【Android Studio】studio学习系列(一) 从eclipse导入project

    Android google官方出的IDE android studio 一直都在走bate版本号,尽管如此,总认为它比ADT更加靠谱.所以我也想用studio来开发滴.可项目一直都是eclipse的 ...

  5. CentOS 安装nload(流量统计)

    yum install gcc gcc-c++ ncurses-devel wget http://www.roland-riegel.de/nload/nload-0.7.2.tar.gz tar ...

  6. HTML构成及基本标签

    超文本标记语言:HTML W3C:互联网联盟 注释语法:<!--注释掉的内容--> 标签格式: 双标签元素:<标签名 属性 style="样式">内容< ...

  7. (转载)log4net 组件详解

    1.概述 log4net是.Net下一个非常优秀的开源日志记录组件.log4net记录日志的功能非常强大.它可以将日志分不同的等级,以不同的格式,输出到不同的媒介.本文主要是介绍如何在Visual S ...

  8. MySQL恢复备份读书笔记

    1. 任何执行时间长于 wait_timeout或interactive_timeout选项值得备份,都会导致会话被关闭,这也会隐含执行UNLOCK TABLES命令.2. 对于使用FLUSH TAB ...

  9. php安全编程—sql注入攻击

    php安全编程--sql注入攻击 定义 SQL注入攻击指的是通过构建特殊的输入作为参数传入Web应用程序,而这些输入大都是SQL语法里的一些组合,通过执行SQL语句进而执行攻击者所要的操作,其主要原因 ...

  10. 【转】Python中执行cmd的三种方式

    原文链接:http://blog.csdn.net/menglei8625/article/details/7494094 目前我使用到的python中执行cmd的方式有三种: 1. 使用os.sys ...