请原谅我对这个话题的无知,因为我对 Hibernate / NHibernate 比较陌生,但我遇到了一个我无法弄清楚的映射:
这是我的数据库表的样子:
<bincontents>
<id>5873715</id>
<title>Video Title</title>
<sortorder>0</sortorder>
<itemid>23079</itemid>
<itemtype>VIDEO</itemtype>
</bincontents>
<bincontents>
<id>5873716</id>
<title>Clip Title</title>
<sortorder>1</sortorder>
<itemid>131854</itemid>
<itemtype>CLIP</itemtype>
</bincontents>
有没有办法用 where 子句一对一映射?
所以 BinContent 对象的 ItemType 可以是 VIDEO 或 CLIP。这些是作为字符串键入的,不幸的是我无法更改。
因此,如果 ItemType 字段显示“VIDEO”,我想要一个多对一“视频”对象,但是如果 ItemType 字段显示“CLIP”,我想要一个多对一剪辑.
帮助!
在这种情况下,我什至不确定是否要使用多对一。也许是一对一?