2012-11-15 2 views
0
내부

나는 다음과 같은 EF 표현이 : 설정시EF 선택 선택

var complexes = db.ResidentialComplexes.AsNoTracking() 
       .Where(rc => rc.MasterEntity == entity) 
       .Select(rc => new CustomComplexObj() 
       { 
        ComplexId = rc.ComplexId, 
        Name = rc.Name, 
        Region = rc.Region, 

        Properties = rc.CurrentProperties.Select(p=> new CustomPropertyObj(){ 
         Name = p.Name, 
         PropertyId = p.PropertyId 
        }).ToList() 

       }).ToList(); 

임에 오류가 점점 : 엔티티에

LINQ는하지 않습니다 :

Properties = rc.CurrentProperties.Select(p=> new CustomPropertyObj(){ 
          Name = p.Name, 
          PropertyId = p.PropertyId 
         }).ToList() 

이 오류입니다 'System.Collections.Generic.List 1[CondoTrack.Model.Poco.CustomPropertyObj] ToList[CustomPropertyObj](System.Collections.Generic.IEnumerable 1 [CondoTrack.Model.Poco.CustomPropertyObj]'메서드를 인식하고이 메서드를 sto로 변환 할 수 없습니다. 다시 표현.

원하는 결과를 얻는 방법에 대한 단서가 있습니까?

+0

무엇이 오류입니까? – CodingGorilla

답변

0

ToList()을 제거하고 List<T> 대신 Properties 유형을 IEnumerable<T>으로 변경하십시오. 오류에서 언급했듯이 ToList은 Linq to Entities에서 지원되지 않습니다.

+0

위대한 !! André에게 감사드립니다. 대답을 수락하기 만하면됩니다. – VAAA