Question

I am using a netdatacontractserializer and a SerializationBinder to create my own runtime types for nhibernate proxies on the client side.

This all works except I am forced to assume that there is only one type by each name in the domain model. i.e. i am forced to ignore the namespace. The reason is that SerializationBinder only gives me access to "MyObjectProxyb04bae2d04d34e8a98b1d93bf24428cc" and "DynamicProxyGenAssembly2, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null" to derive the parent tyep.

As you can see there is no data that points to the namespace of the parent type.

I have had a look at changing the name of the generated proxy (to include a namespace prefix) but that seems to be hard coded.

Was it helpful?

Solution

You can cast the proxy to INHibernateProxy and get the persistent underlying class:

((INHibernateProxy)proxy).HibernateLazyInitializer.PersistentClass
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top