Identifying NHibernate proxy classes
Posted
by Marc Gravell
on Stack Overflow
See other posts from Stack Overflow
or by Marc Gravell
Published on 2010-04-18T22:28:04Z
Indexed on
2010/04/18
22:33 UTC
Read the original article
Hit count: 336
I'm not an NHibernate user; I write a serialization utility library. A user has logged a feature-request that I should handle NHibernate proxy classes, treating them the same as the actual type. At the moment my code is treating them as unexpected inheritance, and throwing an exception.
The code won't know in advance about NHibernate (including no reference, but I'm not aftaid of reflection ;-p)
Is there a robust / guaranteed way of detecting such proxy types? Apparently DataContractSerializer
handles this fine, so I'm hoping it is something pretty simple. Perhaps some interface or [attribute]
decoration.
Also, during deserialization; at the moment I would be creating the original type (not the NHibernate type). Is this fine for persistence purposes? Or is the proxy type required? If the latter; what is required to create an instance of the proxy type?
© Stack Overflow or respective owner