如何在fluent-nhibernate中表示下一个nhibernate xml?

时间:2010-08-28 21:17:21

标签: nhibernate fluent-nhibernate

如何在fluent-nhibernate中表示下一个nhibernate xml?

<set name="Items" lazy="true" table="CATEGORY_ITEMS">
     <key column="CATEGORY_ID"/>
     <composite-element class="CategorizedItem">
          <parent name="Category"/>
          <many-to-one name="Item"
               class="Item"
               column="ITEM_ID"
               not-null="true"/>
          <property name="Username" column="USERNAME" not-null="true"/>
          <property name="DateAdded" column="DATE_ADDED" not-null="true"/>
     </composite-element>
</set>

1 个答案:

答案 0 :(得分:0)

HasMany(x => x.Items)
  .Table("CATEGORY_ITEMS")
  .Component(com =>
  {
    com.ParentReference(x => x.Category);
    com.References(x => x.Item)
      .Not.Nullable();
    com.Map(x => x.Username)
      .Not.Nullable();
    com.Map(x => x.DateAdded)
      .Not.Nullable();
  });

我建议您查看conventions以指定映射的重复部分,例如大写列和表名。