views:

88

answers:

1

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 attribute is optional -->
    </composite-element>
</set>

+3  A: 

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);
  });
James Gregory

related questions