fluent-nHibernate映射

fluent-nHibernate映射,fluent-nhibernate,mapping,Fluent Nhibernate,Mapping,我正在开发一个遗留系统,并引入了fluent nHibernate,但最后一个映射似乎无法使用 代码: 模式: *tblPermit* PermitId, int Discipline, char .... some other columns *tblGas* PermitId, int ....gasDetails *tblElectrical* PermitId, int ....electrical details 如果tblPermit.规程是G,我们需要从tblGas中获取数据

我正在开发一个遗留系统,并引入了fluent nHibernate,但最后一个映射似乎无法使用

代码:

模式:

*tblPermit*
PermitId, int
Discipline, char
.... some other columns

*tblGas*
PermitId, int
....gasDetails

*tblElectrical*
PermitId, int
....electrical details

如果tblPermit.规程是G,我们需要从tblGas中获取数据。如果tblPermit.规程是E,我们需要从tblElectrical中获取数据。我一直在胡思乱想,试图弄明白这一点,但到目前为止还没有任何运气。

在我看来,这个模式是正确的。您可能需要更具体地说明您遇到的问题,因为我认为所有PermitDetails子类的PermitId都成为对应关系表的外键

对于专业气体,相关许可证应包含许可证的气体信息。如果tblGas中的PermitID是tblPermit id的外键,则它具有关系。如下所示:

+---------------+         +----------------------+
|               | 1     1 |                      |
|   tblPermit   |<------->| tblGas               |
|               |         | (for gas discipline) |
|               |         |                      |
+---------------+         +----------------------+
|               |         |                      |
| {PK} PermitId |         | {FK} PermitID        | <- ForeignKey to tblPermit.PermitID
|               |         |                      |
+---------------+         +----------------------+
您不需要“规程”列来选择正确的数据。您只需要一个查询来查找许可证标识符上的tblElectrical、TBLGA。那样的话,你会得到你的许可证和它的信息

请原谅我使用UML类图来可视化数据库表,但是鱼尾纹符号在ASCII中翻译得不好

如果允许,纪律就是我们 需要从TBLGA中获取数据。如果 TBL许可证。纪律是我们需要的 从tblElectrical中获取数据。我 为了得到这个,你在胡闹吗 我知道了,但没有任何运气 到目前为止


鉴别器字段是不相关的,因为子类型的PK字段对于其超类型的表来说是FK。这是每个子类型的表映射

你的图表是正确的。我只是不知道如何编写映射来告诉nHibernate在将数据水合回时加载哪种类型的数据。我自己也不知道该怎么做hibernate最近已经不在我的关注范围之内了。你可以随时查看,如果它有任何想法。
+---------------+         +----------------------+
|               | 1     1 |                      |
|   tblPermit   |<------->| tblGas               |
|               |         | (for gas discipline) |
|               |         |                      |
+---------------+         +----------------------+
|               |         |                      |
| {PK} PermitId |         | {FK} PermitID        | <- ForeignKey to tblPermit.PermitID
|               |         |                      |
+---------------+         +----------------------+