开发者

How to represent next nhibernate xml in fluent-nhibernate?

开发者 https://www.devze.com 2023-01-13 06:32 出处:网络
How to represent next nhiber开发者_运维技巧nate xml in fluent-nhibernate? <set name=\"Items\" lazy=\"true\" table=\"CATEGORY_ITEMS\">

How to represent next nhiber开发者_运维技巧nate xml in fluent-nhibernate?

<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>


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();
  });

I encourage you to look into conventions for specifying the repetitious parts of your mappings, like the uppercase column and table names.

0

精彩评论

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