From now on, but I think the problem here is that the proxy was not initialized before trying to serialize it.
You must call NHibernateUtil.Initialize(aPersistentObject.LazyProperty); to initialize the proxy object.
Then BaseType probably be correct ... i.e. not ProxyDummy , but the actual type is needed.
For me, the solution looks something like this:
namespace com.example.DataAccess { public static class Helper {
So, when I have a REST service endpoint with a proxy type, it looks something like this:
[WebGet(UriTemplate= "foo/{id}/bar")] public Bar GetFooBar(string id) { using (DataAccess.Helper.GetSession()) { var foo = GetFoo(id); if (foo == null) return null; DataAccess.Helper.Initialize(foo.Bar); return foo.Bar; } }
and the serializer defined in WebService.Helper is used to serialize the result.
Please note that if the serialization process happens outside your method (as for me), you always need to call the object initialization before you serialize it. You can do this using Global.asax events, but I just process them directly in my service methods.
source share