【问题标题】:Map a collection映射集合
【发布时间】:2011-07-15 06:20:02
【问题描述】:

我有两张桌子:

Table_A (Id1 PK, Id2)

Table_B (Id1 PK, Id2 PK, Id3 PK)

目标:

table_b 映射到NHibernate 行集作为table_a 对象中的集合

<set name="Table_B_elements" table="Table_B" lazy="true">
                <key columns="Id1"/>
                <one-to-many class="Handler"/>
</set>

我可以很容易地进行类似的查询

select *
from Table_A as a
join Table_B as b on b.Id1 = a.Id2;

对如何映射有任何建议吗?

【问题讨论】:

    标签: c# nhibernate orm


    【解决方案1】:

    是的。阅读http://nhibernate.info/doc/nh/en/index.html#mapping-declaration-join 或此处http://nhibernate.info/doc/nh/en/index.html#collections-mapping,具体取决于您真正想要选择的内容。 这些是 nHibernate 的绝对基础。我建议先阅读文档,然后再询问。

    【讨论】:

    • 我首先阅读了文档,请注意问题出在 Table_B 中的复杂键中。如果你有机会解释它 - 去做吧
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-01-10
    • 2018-03-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-27
    • 2021-12-09
    相关资源
    最近更新 更多