2013-10-09 3 views
4

확장 된 Entity 프레임 워크를 사용하여 일괄 업데이트를 사용하려고하는데 어떻게해야할지 확신이 서지 않습니다.EntityFramework.Extended를 사용하여 일괄 업데이트

지금까지 내가 가지고있는 코드를 다음 : 그것은 1000 개 주문 목록을 반환

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


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

위의 쿼리.

내가 달성하기 위해 노력하고 그래서 : 갱신 OrderListID가에

위 listIds 지금 내가 엔티티 프레임 워크 확장하여 애 쓰고 custListID.

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

어떻게 해결할 수 있는지 알려주십시오.

+0

x => x. listIds의 문자 목록이 올바른 구문이 아닙니다. 이 일을 할 수있는 방법이 있습니까? . 'in'은 올바른 구문이 아닙니다. – Supermode

답변

6

이 구문을 찾고 :

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

Contains는 SQL IN 문으로 변환됩니다.