Ok, having read through the book I understand how the data retrieval operates with the SQL stored procedures in the case of parent and child objects. Basically a single stored procedure retrieves the details for the specified parent object followed by a second resultset containing the details of all the child object. The parent object's DataPortal_Fetch function populates its own fields and then passes the (Safe)DataReader to the factory method of the child class in order that it may construct the child objects.
My question is how do you organise things in the case of a multi-level hierarchy? If you have a Parent/Child/Grandchild situation such that the Child object is both a child and a parent, what's the best way to retrieve the data? You could have a stored procedure to retrieve the details of a specific Parent object which, as described above, would return a second resultset containing a row for each Child object but how would you retrieve the data for each Grandchild object? You can't simply add a third resultset as this would contain all Grandchildren of the Parent in one big "lump" rather than discrete resultsets of Grandchildren for each Child.
Not sure if I'm making myself clear here but if someone can explain the best way of doing this I'd be eternally grateful :)
Toby.
akabak:Ross, do you have any sample code for this? I was just logging on to ask the same question ... I've got a root object that has child contacts, and each child contact has children addresses and children phone numbers related to it.
amanda
I think it would depend. :)
If you have thousands of parent records in a collection, and you are unlikely to want to look at all of the grandchildren, grabbing all the grandchildren for each parent all at once would be wasteful.
But, if you *are* going to be rooting thru most of the grandchildren in your object, then asking for the data one child at a time would be wasteful.
Hope that helps!
Copyright (c) Marimer LLC