Prefetch problem

Posts   
 
    
Jeff M
User
Posts: 250
Joined: 04-Aug-2004
# Posted on: 11-Jul-2005 23:51:01   

Hello LLBLers

Using adapter.

IPrefetchPath2 prefetchPath = new PrefetchPath2((int)EntityType.CatalogueEntity);
prefetchPath.Add(CatalogueEntity.PrefetchPathCatalogueDetails)
                .SubPath.Add(CatalogueDetailEntity.PrefetchPathItem)
prefetchPath.Add(CatalogueEntity.PrefetchPathCatalogueDetails)
                .SubPath.Add(CatalogueDetailEntity.PrefetchPathAccount)

This obviously doesn't work because I'm pefetching the CatalogueDetailEntity twice. But, I can't figure out how to program the graph to retrieve more than one related entity to the CatalgueDetailEntity during the fetch.

Any ideas?

Thanks.

Jeff

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 12-Jul-2005 10:30:55   

This should do it:


IPrefetchPath2 prefetchPath = new PrefetchPath2((int)EntityType.CatalogueEntity);
IPrefetchPathElement2 pathElement = prefetchPath.Add(CatalogueEntity.PrefetchPathCatalogueDetails);
pathElement.SubPath.Add(CatalogueDetailEntity.PrefetchPathItem);
pathElement.SubPath.Add(CatalogueDetailEntity.PrefetchPathAccount);

'Add' returns the element, which is in fact the node in the graph. Call .SubPath is in fact calling the SubPath on the returned element. By placing it into a variable you can build multiple sub-nodes in the graph to make the prefetch path work correctly simple_smile

Frans Bouma | Lead developer LLBLGen Pro