简体   繁体   中英

Batch update using Entity Framework extended

var IDsToUpdate = db.Orders.Where(x => listOfIDs.Contains(x.ID));

db.Orders.Update(IDsToUpdate , x => new Order{ OrderState = "TEST STATE" });

This is producing the runtime error:

The query must be of type ObjectQuery or DbQuery.\\r\\nParameter name: source

I'm using EF 6.0 and EF Extended 6.0 and .NET 4

I need to do a batch/bulk update as performance is not acceptable otherwise.

listOfIDs is of type List<string>

You run the update on the query itself.

db.Orders
.Where(x => listOfIDs.Contains(x.ID))
.Update(x => new Order{ OrderState = "TEST STATE" });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM