I am just getting familiar with the newest framework (3.0) and am having problems with passing the SafeDataReader to my child collection.
I have a simple Client (editable root) that contains Addresses (editable child collection) which contains a collection of Address objects (editable child).
My Client objects DataPortal_Fetch uses a stored proc that returns both the client data and client addresses.
My Code looks like this:
Client DataPortal_Fetch method:
dr.Read();
_id = dr.GetInt32("ClientID");
_firstName = dr.GetString("FName");
_lastName = dr.GetString("LName");
dr.NextResult();
_addresses = Addresses.GetAddresses(dr);
Addresses class GetAddresses method:
internal static Addresses GetAddresess(SafeDataReader dr)
{
return new Addresses(dr);
}
When I am in the Client object the SafeDataReader has data after the NextResult. When I check it again in the Addresses class, it is empty.
I am guessing it is something silly that I am missing but am stumped.
Thanks for any help,
Mike
John,
I have those methods in my addresses class. When it gets to the "while (dr.Read())" it never gets into the add because there are no records. I have backtracked the location where the SafeDataReader is empty and it is at the boundry between my Client and Addresses classes (the code I posted).
Thanks for the suggestion though.
Mike
The SP does return 2 results sets and I an even see the second data set right after I do the dr.NextResult(). By "see" I mean hovering over the object and drilling down to the data. I just loose that data when I check it in the Addresses class.
I've even done:
if (dr.NextResult())
_addresses = Addresses.GetAddresses(dr);
and it does return true and calls the GetAdresses
Mike
Ok. I found something weird. As I step through the code and check the DataSet as I go it looses the data. If I run it without any breaks, it works.
Maybe a bug with VS2008? That would explain why it was so hard to figure out what I did wrong
Thanks for everyones help.
Mike
Copyright (c) Marimer LLC