How to use fluent nhibernate to map a value type collection?

心已入冬 提交于 2019-12-12 05:39:29

问题


.........

<property name="Title" />

<set name ="Contacts" lazy="false" table ="Ad_Contacts">
  <key column="Ad_Id"></key>
  <element type ="String" column="Contact" not-null="true"></element>
</set>

.........

HasMany(x => x.Contacts).AsSet() , which is the statement I used for fluent nhibernate mapping. It doesn't work. Contacts is a collection of string.


回答1:


You could try with the following map:

HasMany<string>(x => x.Contacts).AsElement("Ad_Id");



回答2:


HasMany(x => x.Contacts).AsSet().KeyColumn("Ad_Id").Element("Contact");


来源:https://stackoverflow.com/questions/1243323/how-to-use-fluent-nhibernate-to-map-a-value-type-collection

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