Grandchild Collection

Posts   
 
    
Posts: 134
Joined: 04-Mar-2005
# Posted on: 19-Apr-2005 22:54:47   

What I'd like is to have a (readonly) collection of the grandchild entities available directly from the top-most entity (e.g. Customer.OrderDetails where the OrderDetails are for all the Customer's Orders) so I started adding the appropriate properties to mimic the existing child entity properties to allow me to fetch the OrderDetails in a prefetch with the customer. Am I correct in thinking though that the OrderDetails will not be added to the collection because the FK (OrderID) doesn't match the PK of the containing entity (CustomerID)?

If so is there another way to achieve a grandchild collection or am I just barking up the wrong tree and I should be doing this in a completely different way?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 20-Apr-2005 11:16:12   

A prefetch path merges the childs with the parents. You want to merge the childs with the grandparents, so that's not doable with the prefetch setup.

Though you can fetch them yourself. Selecting all orderdetails for a customer means: SELECT * FROM OrderDetails WHERE OrderID IN (SELECT OrderID FROM Orders WHERE CustomerID = @customerID)

This means a collection fetch for orderdetailentities and a filter which uses a FieldCompareSetPredicate.

Frans Bouma | Lead developer LLBLGen Pro