1 Batch addition     db.T_Investigator.AddRange(list)

2 Batch deletion     db.T_Investigator.RemoveRange(list)

3 Bulk changes    for Cyclic modification .

Be careful : Find out first , Last savechange(), Written in a transaction , One context at a time .

 public int SubmitAll(int[] idList, int userId)
int num = 0;
using (var pmdb = new ProjectManagementEntities())
using (var tran = pmdb.Database.BeginTransaction())
var list = pmdb.T_Investigator.Where(d => idList.Contains(d.InvestigatorID) && d.CreateUserID == userId && d.HasSubmitted == false).ToList();
if (list.Count > 0)
foreach (var item in list)
item.HasSubmitted = true;
num = pmdb.SaveChanges();
catch (Exception ex)
tran.Rollback();// Roll back
throw ex;
} return num;

Online cases :

EF Those batch operations in


EF Batch add to modify More related articles deleted

  1. EF Batch addition , Delete , Modified extensions

    stay EF In all versions , There is no corresponding batch addition , Delete , modify , In use ORM There's an embarrassment in processing data . On the Internet , I have also received a lot of inquiries from netizens , Today I would like to share the related expansion in this aspect ,( This is just an example of batch deletion , Added and modified ...

  2. ASP.NET MVC Batch add and modify data with stored procedure

    use Entity Framework Database interaction , Use... Directly in the code lamda Expression and linq Operation on Database , In the middle, the programmer saves the code time of database access , Programmers can directly focus on the writing of business logic layer . But for the more complicated ...

  3. Windows Batch add and delete IP

    As the weather gets colder , A lot of kids are getting lazy , I want to finish the task in the fastest way Now let's introduce Windows Batch add and delete IP The way to (1) Batch addition IP Directly in CMD Next, run the next command . for /l %i in ...

  4. JavaWeb_day03_ Add, modify and delete employee information

    day03 The addition of employees , modify , Delete Modify the function Ideas : After clicking modify employee data , Jump to single line text , Query the employee to be modified id Full information , Primary key id Set to readonly, The rest can be modified , After the modification , Submit button , Submit ...

  5. EF The solution to the problem of slow performance in batch adding data

    //EF The solution to the problem of slow performance in batch adding data public ActionResult BatchAdd() { using (var db = new ToneRoad.CEA.DbContext.Db ...

  6. Web 1 Three level linkage A drop-down box 2 Add modify delete bounced

    Web   Three level linkage A drop-down box using System; using System.Collections.Generic; using System.Linq; using System.Web; u ...

  7. Open up front and back end full stack development node+vue Advanced 【 Course learning system project in detail 】(3): Users add / modify / Delete vue Table components vue The paging component

    The third chapter Suggested study time 8 Hours       The total project is expected to 10 Chapter Learning style : Read in detail , And manually implement the relevant code ( without node and vue Basics , Please learn the previous vue and node Basic blog [ common 10 Chapter ] Demo address : backstage :demo ...

  8. SpringBoot Timing task upgrade ( Add, modify and delete scheduled tasks dynamically )

    Demand cause : In the release of <Spring Boot Timing task upgrade > And then I got a lot of feedback , One of the feedback is how to dynamically add, modify and delete scheduled tasks ? So let's see how to achieve it , Let's look at the outline of this section first : (1) Train of thought : ...

  9. 【 turn 】C# Add, modify, delete file folder

    [ turn ]C# Add, modify, delete file folder C# Add, modify, delete file folder StreamWriter sw = File.AppendText(Server.MapPath(".")+& ...

Random recommendation

  1. MongoDB replication set Replica set ( Master slave copy )(8)( turn )

    Reprinted address :http://www.cnblogs.com/huangxincheng/p/4870557.html replicattion set That is, multiple servers maintain the same copy of data , Improve server availability ...

  2. xcode There's a hole in it

    Due to changes in project demand , I have to be in coredata Medium WorkLogModel Add a field to the table : Cc people . At first I named this field copyPerson, When everything is ready , Found that reading this from the database copyPerson when , The first ...

  3. Android Pit filling series :Android JSONObject Chinese vs key-value by null Special treatment of

    With the server through JSON Format in the process of interaction , Different versions JSON The library is for key-value by null The situation is handled differently . Android Self contained org.json Yes key-value All ask that we can't do it for null, For must ...

  4. IOS - CORE DATA The catalog of (xcode6)

        When using coredata As app After the background data storage medium of , We'd like to know if the data was successfully inserted . So , I want to find coredata.sqlite The file of The storage directory specified in the code is : - (NSURL *)appli ...

  5. Web Front end html_day1

    1.html structure 1 2 3 4 5 6 7 8 9 10 <!DOCTYPE html>   <html lang="en"> <head> ...

  6. About Oracle dmp File import essay

    I've been in the blog Garden for more than two years , Every time I want to write something , It's all about giving yourself excuses , Settle a matter by leaving it unsettled ~ Today from Oracle Let's start with the longest database import ! 1. Low version of the exp/imp You can connect to higher versions ( Or the same version ) Database server , such as :10 ...

  7. [Oracle][RAC]Oracle RAC Playing in the environment OCW On the individual Patch, then Rollback, Find out OCW Also by Rollback It fell off

    about Oracle RAC Come on , There is a DB Level of Patch, There are also GI Level of Patch. This article introduces ,GI level , hit Patch----> rollback After the action of , The original OCW By Rollba ...

  8. Talk about our understanding of userAgent View of the , Why do reptiles need userAgent?

    First open the browser , Press F12 Access control (Console), Then input :navigator.userAgent, You can see UA. for example : 1 2 Mozilla/5.0 (Windows NT 10.0; ...

  9. vi And vim

    vi Use Basically vi There are three modes , Namely 『 General pattern 』.『 Edit mode 』 And 『 Command line command mode 』. The functions of these three models are : General pattern : With vi Open a file and go directly to the general mode ( This is the default mode ). stay ...

  10. SWERC2015-I Text Processor

    The question Give a length of \(n\) String \(s\), Give me another one \(w\), Ask for all \(i\in [1,n-w+1]\),\(s[i..i+w-1]\) How many different strings are there .\(n,w\le 10^5\). ...