C # dynamic proxy

How can I determine in C # if an object is the original object or a dynamic proxy of the original object?

I ran into this need to play with nhibernate.

+2


a source to share


1 answer


The answer is here in the previous question.



You can tell if a class is NHibernate Proxy by dropping it (unsurprisingly) INHibernateProxy.

If you need to get a "real" object, use:

Session.GetSessionImplementation (). PersistenceContext.Unproxy (proxiedObject) You don't need to check proxies to call Unproxy; it returns the original if it is not a proxy.

+3


a source







All Articles