批量更新扩展
问题描述:
var IDsToUpdate = db.Orders.Where(x => listOfIDs.Contains(x.ID));
db.Orders.Update(IDsToUpdate , x => new Order{ OrderState = "TEST STATE" });
这是生产运行时错误:批量更新扩展
The query must be of type ObjectQuery or DbQuery.\r\nParameter name: source
我使用EF 6.0和EF扩展6.0和.NET 4
我需要做一个批处理/批量更新,否则性能是不可接受的。
listOfIDs
的类型是List<string>
答
您运行查询本身的更新。
db.Orders
.Where(x => listOfIDs.Contains(x.ID))
.Update(x => new Order{ OrderState = "TEST STATE" });
你可以在问题中包含'Update'功能吗? –
更新函数文档在这里: https://github.com/loresoft/EntityFramework.Extended/blob/master/readme.md – neoswarm
@neoswarm你有这个问题的解决方案吗? – Yatin