I need to load up a collection of parent objects, each of which has 2 collections of child objects. I'm wanting to do this in the most efficient way possible and I could use some ideas/input.
One thought I have is to load up the parent objects and then have each parent object know how to cause itself to load child objects in separate queries to the database. What I'm afraid of with this is that if the parent objects are being loaded by iterating through a datareader then I'll have to open a separate connection (and close it) for each collection of child objects. If I load up 100 parent objects that would be a total of 201 connections being opened and closed.
I suppose I could preload a list of IDs and iterate through those IDs loading the individual parent object and subsequent child collections all at once on a per parent object basis. I could do that with one connection but 100 separate hits to the database.
Ideas?
Copyright (c) Marimer LLC