How to map this in Fluent.NHibernate

随声附和 提交于 2019-12-07 19:25:50

问题


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

来源:https://stackoverflow.com/questions/1372399/how-to-map-this-in-fluent-nhibernate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!