The documentation on m:n relations and prefetch paths is rather scant. Hopefully the forum can provide some of the missing details.
Assume a m:n relationship represented by 3 tables A B and C:
A has a 1:n relationship with B
C has 1:n relationship with B
B is thus the intermediate table
We have another table D
D has a 1:n relationship with A
The resulting code LLBL generated code results in 4 entities:
TblAEntity
TblBEntity
TblCEntity
TblDEntity
LLBLGen nicely detects the intermediate relationship and provides a collection TblCCollectionViaTblB for the TblAEntity. So let's assume you want to load TblDEntity and include the prefect paths to retrieve related data, in particular TblC which has no direct relationship to TblD. The code(pseudo) would look something like this:
entityD = New TblDEntity(123)
prefetchPath = New PrefetchPath2(CType(EntityType.TblDEntity, Integer))
prefetchPath.Add(EntityD.PrefetchPathTblA)
prefetchPath.Add(EntityD.PrefetchPathTblCCollectionViaTblB)
adapter.FetchEntity(entityD)
'Accessing the collections of data is now easy from these properties
'entityD.TblA will have a collection of TblAEntity
'entityD.TblCCollectionViaTblB will have a collection of TblCEntity
'entityD.TblB will be empty as the intermediate table data is not retrieved
Alternative way using SubPath, but where is the TblC collection data
entityD = New TblDEntity(123)
prefetchPath = New PrefetchPath2(CType(EntityType.TblDEntity, Integer))
prefetchPath.Add(EntityD.PrefetchPathTblA)
prefetchPath.Add(EntityD.PrefetchPathTblB).SubPath.Add(TblC)
adapter.FetchEntity(entityD)
'Accessing the collections of data is now easy from these properties
'entityD.TblA will have a collection of TblAEntity
'entityD.TblCCollectionViaTblB will have an empty collection of TblCEntity
'entityD.TblB will have a collection of TblBEntity
The question is, in the second example how do you reference the SubPath TblC collection? Where is it in terms of the property to use? I can find the individual items attached to each entity in the TblB collection -When I check entityD.TblB._contents.Items(0).TblC.AnyProperty... - data is set correctly, but the collection is not available.