I'm totally stuck. Please help :)
I am creating a query that returns a set of populated business objects. Lets take the scenario that customers can make orders, orders can contain products and there is a link table between orders and products called orderdetails.
In my business objects, a customer object will have an array of order objects, the orderdetails table will have an array of orders objects and products objects.
In essence, I need to return a set of finite set of customer objects in which all of the related objects are populated.
I have a stored procedure that returns me the relevant data for for each table/set of objects. I can populate the objects with their basic atomic attributes. The problem is setting up the relationships and setting up the arrays of objects. I need to do it as quick as possible :)
This is the only way i could think of (and it's not very good!)
Create the set of customer objects and store in a hashtable in which the key is the primary key of the record
create order objects. as i create the order object, retrieve the relevant customer from the hashtable by its primary key
create products and store in a hashtable in which the key is the primary key of the record, then and store in a hashtable in which the key is the primary key of the record
create order details, as i create order detail object, get the relevant orders and products from hashtable
That seems a total nightmare
Please tell me there is a better way. Next time I will invest in an OR mapper but for now I;m stuck!
Thanks a lot