使用判别器的 Fluent NHibernate 的多级继承
我处于令人羡慕的境地,必须与遗留数据库集成,幸运的是出于只读目的,并且选择使用 NHibernate。到目前为止,一切都很好,但我有一个新的要求,让我摸不着头脑。
在今天之前,我在表中有一列可以充当鉴别器,但现在事实证明,在某些情况下我需要有多个鉴别器列。 NHibernate 可以做到这一点吗?
我研究过使用公式,它有效,但现在我遇到的问题是我需要排除“未知”子类(尚未具有映射的子类)。例如,我有这个:
DiscriminateSubClassesOnColumn("")
.Formula("case ... when ... then ... when .. then ... else 'unknown' end");
我希望能够过滤掉所有“未知”的内容...
编辑:我认为一个可能的解决方案是使用 AlwaysSelectWithValue()
,这意味着什么启用这个有吗?我相信它与 nhibernate 映射 xml 中的 force
相同。
I'm in the enviable situation of having to integrate with a legacy database, luckily for readonly purposes, and have chosen to use NHibernate. Up until now everything has been great, but I have a new requirement which has me scratching my head.
Before today I had one column in the table that would act as a discriminator, but now it turns out that in some cases I need to have more than one discriminator column. Is this possible with NHibernate?
I've looked into using formulas, which works, but now I have the issue that I need to exclude 'unknown' subclasses (ones that don't yet have a mapping). For example I have this:
DiscriminateSubClassesOnColumn("")
.Formula("case ... when ... then ... when .. then ... else 'unknown' end");
I'd like to be able to filter out everything that is 'unknown'...
Edit: I think that a possible solution would be to use AlwaysSelectWithValue()
, what implications does enabling this have? I believe it's the same as force
in the nhibernate mapping xml.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)