Multiple subpaths on a subpath

Posts   
 
    
cwest
User
Posts: 29
Joined: 13-May-2007
# Posted on: 04-Mar-2008 18:15:06   

Is there a way to add multiple subpaths on a subpath?

For example:

Table A

ID

Table B

ID

Table C

ID FKTableAID FKTableBID

Table D - contains metadata about the TableC relationship

ID FKTableCID

Now starting from the top, I want to get an EntityCollection<TableAEntity> populated with the related records from TableC. I then want to populate the EntityCollection<TableC> with both the records from TableB and TableD.

The problem is I can't figure out how to add multiple subpaths on the TableC subpath. I'm kind of getting the impression that this can't be done.

Any ideas on how this can be accomplished?

cwest
User
Posts: 29
Joined: 13-May-2007
# Posted on: 04-Mar-2008 19:58:46   

I've found the answer:

Create a IPrefetchPathElement2 object, for the prefetchs off of TableC. Add subpaths to TableB and TableD on this object. Use the created IPrefetchPathElement2 object in the subpath that prefetches TableC.

Joepsel
User
Posts: 2
Joined: 16-Oct-2007
# Posted on: 27-Aug-2008 09:21:26   

cwest wrote:

I've found the answer:

Create a IPrefetchPathElement2 object, for the prefetchs off of TableC. Add subpaths to TableB and TableD on this object. Use the created IPrefetchPathElement2 object in the subpath that prefetches TableC.

Thanks!

I've been struggling with this for quite a while. I thought it might be useful to post my code here (for future reference):


        PrefetchPath2 path = new PrefetchPath2(EntityType.OfferteEntity);
        path.Add(OfferteEntity.PrefetchPathActiviteit);
        
        IPrefetchPathElement2 subPath = AanvragerProjectEntity.PrefetchPathAanvragerContactpersoon;
        subPath.SubPath.Add(AanvragerContactpersoonEntity.PrefetchPathContactpersoon);
        subPath.SubPath.Add(AanvragerContactpersoonEntity.PrefetchPathProjectRol);

        path.Add(OfferteEntity.PrefetchPathAanvragerProject).SubPath.Add(subPath);