결과가 여전히 구성 가능하도록 LinqToSql (또는 EF) 쿼리에서 여러 엔터티를 반환 할 수 있습니까 (쿼리가 메서드 내에 있음)? 이 같은LinqToSQL (또는 EF)에서 여러 엔터티 반환
뭔가 :
public IQueryable<KeyValuePair<Customer, Product>> GetCustomerEntities()
{
return
(
from customer in this.Context.Customers
join
product in this.Context.Products on customer.ID equals product.CustomerID
select new KeyValuePair<Customer, Product>(customer, product)
);
}
가 그럼 난 더 같은 쿼리를 작성하는 데이 방법의 결과를 사용하려면 :
this.GetCustomerEntities().Where(e => e.Key.Name == "my customer")
컴파일 위의 방법 만이 실행할 수 없습니다 LinqToSql에 의해 KeyValuePair을 SQL로 변환 할 수 없으므로 예상되는 동작입니다.
어떻게 든이를 달성 할 수 있습니까?
감사합니다. 작동합니다! 먼저 SQL을 실행하지 않고 쿼리를 작성할 수 있습니다. – SzilardD