linq 쿼리를 사용하여 일부 외래 키 데이터를 미리 가져 오려고합니다. 내 문제를 설명하는 빠른 예는 다음과 같습니다LINQ : 두 번째 테이블에서 데이터 프리 패치
var results = (from c in _customers
from ct in _customerTypes
where c.TypeId == ct.TypeId
select new Customer
{
CustomerId = c.CustomerId,
Name = c.Name,
TypeId = c.TypeId,
TypeName = ct.TypeName, <-- Trying to Prefetch this
}).ToList();
고객 클래스는 다음과 같습니다
[Table(Name = "Customers")]
public class Customer
{
[Column(Name = "CustomerId", IsPrimaryKey = true, IsDbGenerated = true, AutoSync = AutoSync.OnInsert)]
public int CustomerId { get; set; }
[Column(Name = "Name")]
public string Name { get; set; }
[Column(Name = "TypeId")]
public int TypeId { get; set;}
public string TypeName { get; set; }
public Confession(){}
}
그러나 LINQ는이 엔티티 타입 '고객'을 명시 적으로 건설 "과 NotSupportedException이 던지는 않는 못하게 쿼리가 허용되지 않습니다. "
분명히 잘못 접근하고 있습니다. 올바른 방향의 포인터가 가장 도움이 될 것입니다.