开发者

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

开发者 https://www.devze.com 2023-01-01 19:10 出处:网络
How do we express this in FNH? <class name=\"Order\" .... > .... <set name=\"PurchasedItems\" table=\"purchase_items\" lazy=\"true\">

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

精彩评论

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