Fluent Nhibernate How to specify Id() in SubclassMap

梦想的初衷 提交于 2019-12-05 21:26:04

It's not possible to do that in either Fluent NHibernate or NHibernate. Do you actualy want your classes to be mapped as subclasses, or do you just want them to share the common mappings? If you truly want subclasses, then you're going to need to have them share the identity column, no other way around it; if you don't want actual subclasses, create an abstract ClassMap<T> where T : BaseObject and map the common properties in there.

Something like:

public abstract class BaseObjectMap<T> : ClassMap<T> where T : BaseObject
{
  public BaseObjectMap()
  {
    Map(x => x.CommonProperty1);
  }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!