I'm trying serialize some objects through wcf. So, for performance reason, I have some collections configured with lazy=true. However, this proxy doesn't work with wcf. So, I made a solution based on the Tim Vasil solution.
http://timvasil.com/blog14/post/2008/02 ... rnate.aspxIn his solution he force initialization of collections with lazy=true because it can't be initialized in te client. Otherwise, in my solution if i don't force fetch mode in the moment of query so the collection will not be necessary on the client. Is there any way to instantiate a a empty collection or a return null without problem?
Tim Vasil
Code:
// Serialize persistent collections as the collection interface type
if (obj is IPersistentCollection)
{
IPersistentCollection persistentCollection = (IPersistentCollection)obj;
persistentCollection.ForceInitialization();
obj = persistentCollection.Entries(); // This returns the "wrapped" collection
}
I made the code bellow but it doesn't work.
Code:
if (obj is IPersistentCollection) {
IPersistentCollectioncoll = (IPersistentCollection)obj;
if (!coll.WasInitialized){
obj = null;
}
}