Problems with PrefetchPath SubPath (m:1)

Posts   
 
    
Arif
User
Posts: 29
Joined: 01-Dec-2005
# Posted on: 03-Mar-2006 22:23:50   

I am trying to Prefetch a 3rd level entity using PrefetchPaths.

I have the following code:

The root EntityCollecton and the adapter's fetch:


EntityCollection orderColl = new EntityCollection(new OrderEntityFactory());
...
adapter.FetchEntityCollection(orderColl, bucket, BuildPrefetchPaths());

The summarized BuildPrefetchPaths logic


private IPrefetchPath2 BuildPrefetchPaths()
{
PrefetchPath2 prefetch = new PrefetchPath2((int)EntityType.OrderEntity);

 PrefetchPathElement2 schedPrefetch = (PrefetchPathElement2)OrderEntity.PrefetchPathScheduleItem;
                    if (_prefetchScheduleItemEmployee)
                    {
                        schedPrefetch.SubPath.Add(ScheduleItemEntity.PrefetchPathEmployee);
                    } 
                    
                    prefetch.Add(schedPrefetch, 0, null, null, new SortExpression(ScheduleItemFields.StartDateTime | SortOperator.Ascending));

return prefetch;
}

The problem is that it does not fetch the Employee from the ScheduleItem using: schedPrefetch.SubPath.Add(ScheduleItemEntity.PrefetchPathEmployee);

This is a m:1 relation between ScheduleItem & Employee. Watching SQL Profiler, no SQL is generated for this sub-fetch. However, if I change this to another m:1 relation (ScheduleItemEntity.PrefetchPathScheduleType) it does generate the SQL for the sub-fetch.

What would cause one m:1 SubPath prefetch to generate SQL & the other to go dormant & not generate any sql nor runtime error?

Arif
User
Posts: 29
Joined: 01-Dec-2005
# Posted on: 04-Mar-2006 00:30:56   

Nevermind, this is working now. I just recompiled the entire solution & that fixed it.