Yes, it can be helpful for me.

 The problem that i have with AutoMapper or the process of serialization is 
that can´t control if a property is loaded previously. These automated 
process get the value of Lazy items with a LazyLoadingException if session 
is closed or loading objets that don´t want to pass to other layers with 
possible circular references.

  Implementing a method using reflection with 
the NHibernateUtil.IsInitialized(), like says Fabio (TEntity 
TransformToDto(TEntity entity)) I can control the access of this properties 
and create a copy of this instance like a DTO and work with it and 
serialize with only the previusly loaded properties.

  This isn´t the solution that I'm searching, because i have to make a 
copy, but if NHibernate can´t provide another solution like detaching and 
object and turn it into a simple POCO, this is a possible patch.
 
  Another possibility is manipulate the code of NHibernate, adding a new 
property to the SessionFactory and modifiying the code to avoid the throw 
of the LazyLoadingException if this flag is enabled and the Entity is 
detached

Reply via email to