Prefetch Path

Posts   
 
    
Posts: 1
Joined: 20-Feb-2008
# Posted on: 20-Feb-2008 17:23:48   

Is there a difference in the generated results when using a subpath to define the relationship vs an prefetech path add statement see code below

prefetchPath = new PrefetchPath2((int)EntityType.HCClientCallRecordEntity); prefetchPath.Add(HCClientCallRecordEntity.PrefetchPathUser); prefetchPath.Add(HCClientCallRecordEntity.PrefetchPathHCClientDetails).SubPath.Add(HCClientDetailsEntity.PrefetchPathClient);

vs.

prefetchPath = new PrefetchPath2((int)EntityType.HCClientCallRecordEntity); prefetchPath.Add(HCClientCallRecordEntity.PrefetchPathUser); prefetchPath.Add(HCClientCallRecordEntity.PrefetchPathHCClientDetails); prefetchPath.Add(HCClientCallRecordEntity.PrefetchPathClientCollectionViaHCClientDetails);

I would like to confirm if there is a difference in performance or generated code.

Both statements are using HCClientDetails as the joining entity to going the client collection.

Thanks

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 20-Feb-2008 19:10:00   

lawrenson2008 wrote:

prefetchPath = new PrefetchPath2((int)EntityType.HCClientCallRecordEntity); prefetchPath.Add(HCClientCallRecordEntity.PrefetchPathUser); prefetchPath.Add(HCClientCallRecordEntity.PrefetchPathHCClientDetails).SubPath.Add(HCClientDetailsEntity.PrefetchPathClient);

This allows you to navigate and explore the intermediate entities. For example:

somevalue = theRecordsResults[_someRecord].HCClientDetails[_someClientDetail].SomeField;

// or
int countClientDetailOfSomeRecord = theRecordsResults[_someRecord].HCClientDetails[_someClientDetail].Count;

// etc.

lawrenson2008 wrote:

prefetchPath.Add(HCClientCallRecordEntity.PrefetchPathClientCollectionViaHCClientDetails);

Here you can: - Access the ClientCollection in this way:

someValue = theRecordsResults[_someRecord].ClientCollectionViaHCClientDetails[_someClient].SomeField;

but you cant access some HCClientDetails object and then access its Client collection (or entity).

Copied from manual(LLBLGenProHelp - Using the generated code - Adapter - Prefetch paths - Advanced Prefetch Paths - M:N related entities):

M:N related entities Prefetch Paths can also be used to fetch m:n related entities, they work the same as other related entities. There is one caveat: the intermediate entities are not fetched with an m:n relation Prefetch Path. For example, if you fetch a set of Customer entities and also their m:n related Employee entities, the intermediate entity, Order, is not fetched. If you specify, via another PrefetchPathElement2, to fetch the Order entities as well, and via a SubPath also their related Employee entities, these Employee entities are not the same objects as located in the Employees collection of every Customer entity you fetched.

David Elizondo | LLBLGen Support Team