NHibernate mapping with a class hierarchy whose base class is abstract and the discriminator is not a string

廉价感情. 提交于 2019-12-03 06:25:13

I have found a workaround but this seems so like a patch... I added the following to the mapping file:

SetAttribute("discriminator-value", "-1");

It seems to instruct FNH not to use a string (I think it uses the class name) for the abstract base class. To make it work with the -1 value, I also changed my discriminator type from byte to sbyte.

Edit: I missed that: this is the second parameter to DiscriminateSubClassesOnColumn that takes the default value. So the correct answer to my question is:

DiscriminateSubClassesOnColumn<sbyte>("Type", (sbyte)-1)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!