Hi,
I am creating a group of nested objects that relate to one parent object and am a bit stuck in the process (I am using CSLA.NET CodeSmith templates from the CSLAContrib project).
Ok so I have one root object ROOTOBJECT, It has 1 child object CHILD1 and a collection of child1 is a member of ROOTOBJECT
ie CHILD1COLLECTION is a member of ROOTOBJECT
The Child objects have a collection of sub-child objects SUBCHILD1_COLLECTION is CHILD1's collection
Now ROOTOBJECT has a ROOT_SelectProcedure that selects the root object and then calls CHILD1_SelectByRootId that selects all Child1 objects that have a foreign key to the ROOTID field. The CHILD1_SelectByRootId also calls SUBCHILD1_SelectByChild1ID to get all sub-child objects for Child1.
Ok now in the code for ROOTOBJECT1, it calls FetchObject which gets a datareader, reads its own fields, calls GetnextResultSet and passes the datareader to CHILD1COLLECTION, which loops to read from the datareader and then calls the constructor of the CHILD1 object, passing in the datareader. CHILD1 builds its fields from the datareader and then calls GetNextResultSet to build its CHILD1COLLECTION. Here is where the problem is because CHILD1COLLECTION is still reading from the datareader in a while loop and as soon as GetNextResultSet is called, the loop breaks and I only get 1 item for CHILD1COLLECTION.
Surely, there must be a better way to do this. I want to work with the CSLA.NET templates and not change its core pattern by much. Does anyone have a best practice on how nested child collections can be fetched? Many Thanks, Shailen Sukul
With Regards
Shailen Sukul (Software Architect/Developer)
BSc Mcpd Mcts (Web, Win, Dis Apps) Mcsd.Net Mcsd Mcad
http://www.ashlen.com.au