Hello everybody,
I'm using lazy loading and .NET remoting and everything works fine.
..but I have a little question only:
I have a Master - father table and a MasterDetail - child table.
In my remoting environment I have the following methods:
public IList ReconnectSession(ItemBase obj, IList aCollection)
{
try
{
NHibernate.Collection.PersistentCollection tCollection = aCollection as NHibernate.Collection.PersistentCollection;
if (aCollection != null && !NHibernateUtil.IsInitialized(aCollection))
{
openSession();
_session.Lock(obj, LockMode.None);
NHibernateUtil.Initialize(aCollection);
}
}
catch (Exception)
{
throw;
}
finally
{
closeSession();
}
return aCollection;
}
but in the client side, after the execution of reconnectSession method, I need to execute the following piece of code to reassign the father:
foreach (MasterDetail md in MasterDetailsCollection)
{
md.Master = this;
}
this is necessary because when the instance of Master pass through the remoting boundary becomes a NEW istance, different from my old one.
I don't like this way to solve the problem, any suggestions?
Thanks
Antonella :)
|