문제

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