2

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.

Gert Arnold
  • 105,341
  • 31
  • 202
  • 291
Supermode
  • 924
  • 3
  • 32
  • 53
  • x => x.OrderListID in listIds is not correct syntax. Is there any way to do this? . 'in' is not correct syntax – Supermode Oct 09 '13 at 13:16

1 Answers1

4

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.

Gert Arnold
  • 105,341
  • 31
  • 202
  • 291