Hey guys i'm trying to figure out if there is a way to fetch a Parent list (e.g Customer Sales) together with its children (e.g Sales Items) in 1 data-reader without going back to the database and opening a new reader for each child item
Sure you can, at least with SQL Server.
Just make sure to set MARS (multiple active result sets) on in your connection string.
Hi thanks for the answer i appriciate this
but let me ask you how do i set this up in a DataPortal_Fetch of two class what do i need to pass in at the child level object Is It a reader or a Command
Read more about MARS here:
http://msdn.microsoft.com/en-us/library/haa3afyz%28v=vs.71%29.aspx
You might also want to check this dnrTV episode (http://www.dnrtv.com/default.aspx?showNum=60). Rocky did a presentation on using CSLA.net as a Data Access Layer. Around 12:40 into the episode he talks how to query for the Parent-Child-GrandChild all from the parent.
Have a look at DeepLoad sample http://cslagenfork.codeplex.com/releases/view/79758
This code was generated by CslaGenFork but you can use it as an example of fecthing a data structure 6 levels deep in a single round trip to the database. And it uses a single data reader...
Copyright (c) Marimer LLC