How to map this in Fluent.NHibernate

2019-05-18 12:11发布

I'd like to get this output from fluent.nhibernate

<map name="Dict" table="TABLE">
  <key column="ID_USER" />
  <index-many-to-many column="ID_TABLE" class="TableClass" />
  <element column="COL" type="Int32" />
</map>

where class has:

public class User
{
    public virtual IDictionary<TableClass, int> Dict { get; protected set; } 
}

Closest I've got to is this:

HasMany(x => x.Dict)
         .Table("TABLE")
         .KeyColumn("ID_USER")
         .AsMap<TableClass>("ID_TABLE")
         .Element("COL");

And the output for that is:

<map name="Dict" table="TABLE">
  <key>
    <column name="ID_USER" />
  </key>
  <index type="TableClass">
    <column name="ID_TABLE" />
  </index>
  <element type="Int32">
    <column name="COL" />
  </element>
  <one-to-many class="Int32" /> <!-- BUG -->
</map>

How can I remove the last line (marked with BUG)?

It's not always needed (like in my example it isn't)!

0条回答
登录 后发表回答