3

私はこれらの2つのクラスを持っています:

    public class Category
        {
            IDictionary<string, CategoryResorce> _resources;
        }

    public class CategoryResource
        {
            public virtual string Name { get; set; }
            public virtual string Description { get; set; }
        }

これはxmlマッピングです

<class name="Category" table="Categories">
  <id name="ID">
    <generator class="identity"/>
  </id>
  <map name="Resources" table="CategoriesResources" lazy="false">

      <key column="EntityID" />
      <index column="LangCode" type="string"/>

      <composite-element class="Aca3.Models.Resources.CategoryResource">
        <property name="Name" column="Name" />
        <property name="Description" column="Description"/>
      </composite-element>
  </map>
</class>

Fluentで書きたいと思います。私は似たようなものを見つけて、このコードで試していました:

  HasMany(x => x.Resources)
                .AsMap<string>("LangCode")
                .AsIndexedCollection<string>("LangCode", c => c.GetIndexMapping())
                .Cascade.All()
                .KeyColumn("EntityID");

しかし、CategoryResourceエンティティをCategory要素内の複合要素としてマップする方法がわかりません。

何かアドバイス ?

ありがとう

4

1 に答える 1

4

あなたが探しているマッピングは次のようなものだと思います:

HasMany<CategoryResource>(x => x._resources)
.AsMap<string>("LangCode")
.KeyColumn("EntityID")
.Table("CategoryResources")
.Component(x =>
    {
        x.Map(c => c.Name);
        x.Map(c => c.Description);
    })
.Cascade.All();
于 2010-05-11T01:52:47.810 に答える