proxy classes - After calling NHibernate.Initialize(proxyObject) I'm getting wrong objectType -
I have an object hierarchy> Parents> Children (lazy loading is set to true by default) Now I have all the parent objects The loading data will be the type of childproof in all the child's object from the database.
Then I
IList & lt; Parent & gt; Parents = NHibernateHelper.List & lt; Guardian & gt; (); Foreign currency (parent parent's parent) {if (NHibernateUtil.IsInitialized (parent.Child)) {NHibernateUtil.Initialize (parent.Child); If (parents- child.gettype ()! = Typed (hair)) // parent.Child.GetType () Please type proxy back to me new logic concept ("wrong type"); }}
How can I change my parents? Due to checking the child's actual type "hair" system, I need real type (hair). This example is simple in real life. I have very complex mapping and relationship.
Any thoughts?
Try with:
var realObject = session. GetSessionImplementation () PreistenceContext.Unproxy (parent.Child)
However, it is a bad idea to trust your code in this type of check because it violates code, it is difficult to maintain code. .
Comments
Post a Comment