I am trying to use batch update using Entity framework extended but i am unsure how to do this.

So far this the following code that i have:

List<Guid> listIds = new List<Guid>();


listIds = listIds.Union(hem.ProductList.Where(x => x.CustListID == custListID).ToList().Select(y => y.OrderListID)).ToList();

with above query it return 1000 Order lists.

So what I am trying to achieve: update the custListID where OrderListID in listIds above

Now I am trying using the Entity Framework extended.

using (var db = new DBContextEntities())
{
    var rowUpdates = db.ProductList.Update(x => x.OrderListID in listIds, x => new ProductList { CustListID = custListID});
}

Please advise how I can achieve this.

有帮助吗?

解决方案

You're looking for this syntax:

db.ProductList.Update(x => listIds.Contains(x.OrderListID),
                           x => new ProductList { CustListID = custListID });

Contains is translated to a SQL IN statement.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top