M6rk wrote:
Using the "Selfservice" model:
Given the following tables, and assuming child entities are suffixed with the text "Items":
Grandparent
[id]
[name]
Parent
[id]
[grandparentId]
[name]
Child
[id]
[parentId]
[name]
How would you code to get all the Grandparent objects, prefeching all parent and all child objects with and without filtering?
GrandparentCollection grannies = new GrandparentCollection();
IPrefetchPath prefetcher = new PrefetchPath((int)EntityType.Grandparent);
prefetcher.Add(GrandparentEntity.PrefetchPathParentItems).SubPath.Add(
ParentEntity.PrefetchPathCHildItems);
grannies.GetMulti(null, prefetcher);
This should be it.
It's a little hidden in hte prefetch path docs, half way on the page:
The example above is a rather simple graph, just two nodes. LLBLGen Pro's Prefetch Path functionality is capable of handling much more complex graphs and offers options to tweak the fetch actions per PrefetchPathElement2 object to your liking. To illustrate that the graph doesn't have to be linear, we'll fetch a more complex graph: a set of Customer entities, all their related Order entities, all the Order's Order Detail entities and the Customer entities' Address entities. The example illustrates how to use sublevels in the graph: use the SubPath property of the PrefetchPathElement object used to build graph nodes with.