How to map this Dictionary with the newest fluentNHibernate version?

社会主义新天地 提交于 2020-01-06 04:51:06

问题


i've got one more question. I upgraded to FluentNHibernate and got now a problem with my dicitionary mappings.

The class i'am trying to map has the following Property

IDictionary LohnParameter

The mapping is as follows

HasMany(x => x.LohnParameter) 
     .ForeignKey("cat_condition_version__id") 
     .DictionaryKey("wrd_cntry__id") 
     .OneToMany<boLohnartEigenschaften>() 
     .Not.Lazy() 
     .Inverse() 
     .Cascade.AllDeleteOrphan();

The resulting hbm.xml looks like this:

<map cascade="all-delete-orphan" inverse="true" lazy="false" name="LohnParameter" table="boLohnartVersionLohnParameter" mutable="true">
        <key>
          <column name="cat_condition_version__id" />
        </key>
        <index-many-to-many class="proSoft.Office.Model.Business.Welt.boLand, proSoft.Office.Model.Business, Version=0.1.19.20243, Culture=neutral, PublicKeyToken=b0e4f89242e69335">
          <column name="wrd_cntry__id" />
        </index-many-to-many>
        <one-to-many class="proSoft.Office.Model.Business.Konditionen.boLohnartEigenschaften, proSoft.Office.Model.Business, Version=0.1.19.20243, Culture=neutral, PublicKeyToken=b0e4f89242e69335" />
      </map>

With the new version, the compiler complains, that the Property "ForeignKey" is missing. I tried now everything, but i can't get it to work properly. My last try was:

  HasMany(x => x.LohnParameter) 
     .AsMap<boCountry>( 
       index => index.Column("wrd_cntry__id").Type<boCountry>(), 
       element => element.Type<boLohnartEigenschaften>() 
     ) 
     .KeyColumn("cat_condition_version__id") 
     .Not.LazyLoad() 
     .Inverse() 
     .Cascade.AllDeleteOrphan();

But the error i always get is:

{"Could not determine type for: proSoft.Office.Model.Business.Welt.boCountry, proSoft.Office.Model.Business, Version=0.1.14.556, Culture=neutral, PublicKeyToken=b0e4f89242e69335, for columns: NHibernate.Mapping.Column(wrd_cntry__id)"}

I don't have clue what do do.

Regards

Christian Erhardt


回答1:


i think you searching for this

HasMany(x => x.LohnParameter) 
    .AsEntityMap("wrd_cntry__id")



回答2:


Thank you for the hint, it was the right way. The correct mapping is this:

     HasMany(x => x.LohnParameter)
        .KeyColumn("cat_condition_version__id")
        .AsEntityMap("wrd_cntry__id")         
        .Not.LazyLoad()
        .Inverse()
        .Cascade.AllDeleteOrphan();

This results in exact the same hbm.xml file.

Thank you!



来源:https://stackoverflow.com/questions/7443907/how-to-map-this-dictionary-with-the-newest-fluentnhibernate-version

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