gpt4 book ai didi

c# - 如何使用 FK NHibernate 映射复合 PK

转载 作者:太空宇宙 更新时间:2023-11-03 14:10:39 25 4
gpt4 key购买 nike

我想映射这样的东西:

表 FOO:复合 PK:ID_OTHERFOOFK1 (PFK)、ID_OTHERFOOFK2 (PFK)、ID_FOO (PK)

表OTHERFOO1关系:OTHERFOO1一对多FOO表OTHERFOO2关系:OTHERFOO2一对多FOO

类(class)会是什么样子?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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com