我想映射这样的东西:
表FOO:COMPOSITE PK:ID_OTHERFOOFK1(PFK),ID_OTHERFOOFK2(PFK),ID_FOO(PK)
表OTHERFOO1关系表:OTHERFOO1一对多FOO
表OTHERFOO2关系表:OTHERFOO2一对多FOO
上课的样子如何?
hbm.xml的外观如何?
最佳答案
class Foo
{
public virtual int Id { get; set; }
public virtual Foo1 Foo1 { get; set; }
public virtual Foo2 Foo2 { get; set; }
}
class Foo1
{
public virtual int Id { get; set; }
}
class Foo2
{
public virtual int Id { get; set; }
}
<composite-id>
<key-property name="id" column="ID_FOO"/>
<key-many-to-one name="Foo1" column="ID_OTHERFOOFK1"/>
<key-many-to-one name="Foo2" column="ID_OTHERFOOFK2"/>
</composite-id>
关于c# - 如何使用FK NHibernate映射复合PK,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7972443/