Hi,
My object looks something like this:
class
{
int a;
object b;
IList<string> c;
}
All the fields are getting populated from the database and the collection is getting lazy initialization which is desirable. Now, my problem is that I want to send this object to the web service. But since the collection is lazily loaded, am not able to do it. Can somebody please give me an idea or a direction or some example code which I can look into for my problem.
I want a generic way to force initialization for this list before I send it over the wire. Also, I have multiple objects like this so a generic way to do it would be great. Right now, to do this I am using this method:
public static T Unlazy<T>(this T persistentCollection)
{
if (persistentCollection is IPersistentCollection)
{
IPersistentCollection collection = (IPersistentCollection)persistentCollection;
collection.SetCurrentSession(session.GetSessionImplementation());
collection.ForceInitialization();
}
}
But this throws an object reference set to null exception for some reason
Thanks.