开发者

Fluent-NHibernate: How does one translate composite-element tag to fnh?

How do we express this in FNH?

<class name="Order" .... >
....
<set name="PurchasedItems" table="purchase_items" lazy="true">
    <key column="order_id">
    <composite-element class="Purchase">
        <property name="PurchaseDate"/>
        <property name="Price"/>
        <property name="Quantity"/>
        <many-to-one name="Item" class="Item"/> <!-- class开发者_JAVA百科 attribute is optional -->
    </composite-element>
</set>


This should do it:

HasMany(x => x.PurchasedItems)
  .Component(c =>
  {
    c.Map(x => x.PurchaseDate);
    c.Map(x => x.Price);
    c.Map(x => x.Quantity);
    c.References(x => x.Item);
  });
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜