2

我在 Nhibernate hbm 文件中有一个类,为此我使用复合 id 字段,方式如下:

 <composite-id>
    <key-many-to-one name="DContent" class="Business.Entities.DContent, Business" column="DId" />
    <key-many-to-one name="Structure" class="Business.Entities.Structure, Business" column="RId"/>
    <key-property name="Language"></key-property>
 </composite-id>

</class>

其中 DContent 和 Structure 是类,Language 是一个 int。

我已经覆盖了 Equals 和 GetHashCode 方法,以跟踪复合键中的 3 个对象,但我发现当它在数据库中创建表时,只有两个 DId 和 RId 是主键的一部分,而不是语言。

我的问题是:为什么 NHibernate 看不到语言是主键的一部分?

谢谢你,卡塔林

4

0 回答 0