0
나는 EF4에서 쿼리를 사용하여 데이터를 기반으로 다양한 다른 방법 (EF 아님)을 통해 레코드 및 프로세스 정보를 가져 오므로 목록에서 EF 개체를 자주 분리합니다.엔티티 프레임 워크 4 관련 엔티티가로드되지 않음
이 경우, .Include ("...") 메서드를 사용하고 있어도 EntityFramework 4.0에서 관련 엔터티를로드하지 않는 쿼리가 있습니다.
using (MyDBEntities ctx = new MyDBEntities())
{
ctx.ContextOptions.LazyLoadingEnabled = false;
// Get the first X records that need to be processed
var q = (from t in ctx.DBTables
.Include("Customer")
let c = t.Customer
where t.statusID == (int)Enums.Status.PostProcessing
&& c.isActive == true
select t
).Take(batchSize).ToList();
foreach (DBTable t in q)
{
// this results in c == null
Customer c = t.Customer;
// However t.CustomerID has a value, thus I know
// that t links to a real Customer record
Console.WriteLine(t.CustomerID);
}
}
명시 적으로 명시하고 있지만 고객이 왜로드하지 않는지 이해하는 사람은 누구입니까?
'batchSize'란 무엇입니까? 'foreach' 루프를 사용하여 단계를 밟을 때 얼마나 많은 레코드가 있는지 알 수 있으며 어떤 값을 볼 수 있습니까? –
batchSize는 훨씬 이전에 함수에 전달되는 int입니다. – Jerry