Issue with Casting proxies when using NHibernate table per subclass inheritance strategy

前端 未结 1 1731
挽巷
挽巷 2020-12-15 09:54

I have got an abstract base class and inherited poco entities. I am using table per subclass inheritance with fluent nhibernate 1.1 automapping.

The class inheritan

相关标签:
1条回答
  • 2020-12-15 10:31

    This is well explained by Oren here: http://ayende.com/Blog/archive/2009/09/03/answer-the-lazy-loaded-inheritance-many-to-one-association-orm.aspx

    In a nutshell, proxies inherit from the type of the association, not the inherited type, because that is not known before going to the DB (and you can't change the type of an object)

    Update: a possible workaround is leaking a reference to the actual object in Node:

    public virtual Node Self { get { return this; } }
    

    That will give you the underlying Asset or Place. Be careful with it.

    0 讨论(0)
提交回复
热议问题