I define:
[ActiveRecord("BaseEntity", Lazy = true )] class BaseClass {} [ActiveRecord("DerivedEntity", Lazy = true )] class DerivedClass : BaseClass {}
In DB BaseEntity and DerivedEntity: 1 = 1
I'm creating:
BaseClass myClass = New DerivedClass();
Problem:
When i try to ask
myClass is DerivedClass
I get "false" because myClass is not a DerivedClass, but a base class.
Without Lazy Loading, NHibernate does not create a proxy object, and I do not have this problem.
When I try to use myClass for DerivedClass, I get this error (obviously) because I'm trying to apply a BaseClassProxy object to DerivedClass.
Unable to cast object of type 'Castle.Proxies.BaseClassProxy' to type 'DerivedClass'.
Questions:
Thanks for answers.
source share