Prefetch Path Error

Posts   
 
    
MikeP
User
Posts: 40
Joined: 27-May-2007
# Posted on: 07-Dec-2007 13:34:15   

Good Afternoon,

I have been trying to make sense of prefetch paths all afternoon yesterday but even searching through these forums I am still not sure I understand fully (which is probably due to me being new to LLBL so please bear with me).

I am using LLBL in adapter mode and I am trying to prefetch the following data structure in one go:

The database has three main tables : Missions, Fllights and Sectors. Each mission can have many flights and each flight in turn can have many sectors. So far this seems straight forward and I have been able to fetch all records by the following prefetch path:

prefetchPath.Add(MissionEntity.PrefetchPathFlight).SubPath.Add(FlightEntity.PrefetchPathSector);

However the Flight Entity has a one to many relation to a Route (each flight can have many route points). I can fetch this routepoint collection with the following prefetch path:

prefetchPath.Add(MissionEntity.PrefetchPathFlight).SubPath.Add(FlightEntity.PrefetchPathRoute);

When I try to combine the two:

prefetchPath.Add(MissionEntity.PrefetchPathFlight).SubPath.Add(FlightEntity.PrefetchPathSector);
prefetchPath.Add(MissionEntity.PrefetchPathFlight).SubPath.Add(FlightEntity.PrefetchPathRoute);

the following error is raised:

“The PreFetch Path elemet you are trying to add is already added to this prefetch path.”

Is there a way to achieve this or how should I split this into more entities? Any help is much appreciated!

Thanks,

Mike

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 07-Dec-2007 15:21:36   

Is there a way to achieve this or how should I split this into more entities? Any help is much appreciated!

Yes sure please try the following:

PrefetchPathELement flightPrefetchPathElement = prefetchPath.Add(MissionEntity.PrefetchPathFlight);

flightPrefetchPathElement.SubPath.Add(FlightEntity.PrefetchPathSector);
flightPrefetchPathElement.SubPath.Add(FlightEntity.PrefetchPathRoute); 
MikeP
User
Posts: 40
Joined: 27-May-2007
# Posted on: 10-Dec-2007 11:09:07   

Hello Waala,

Works a treat, thanks again for your help! I didn't appreciate that you can split the prefetch path into elements and therefore preventing including one element twice which produces the error. Maybe I just missed this but I don't think I came across it in the manual?

Regards,

Mike

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 10-Dec-2007 11:31:36   

Maybe we need to put a code example of this in the manual. Thanks.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39908
Joined: 17-Aug-2003
# Posted on: 11-Dec-2007 11:21:56   

Good idea, I'll add an item to the tracker.

Frans Bouma | Lead developer LLBLGen Pro