开发者

How to map this Dictionary with the newest fluentNHibernate version?

开发者 https://www.devze.com 2023-04-05 03:08 出处:网络
i\'ve got one more question. I upgraded to FluentNHibernate and got now a problem with my dicitionary mappings.

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


i think you searching for this

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


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!

0

精彩评论

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

关注公众号