Fluent NHibernate - How map an IList<Enum> as list of strings

心不动则不痛 提交于 2019-12-11 08:13:09

问题


I have a class with IList<Role> roles as a property which is mapped by the following code:

 map.HasMany(u=>u.roles).Element("role").Cascade.All()

but this maps roles to a column of int but I want it to be mapped to a column of string.


回答1:


use the override to specify the NHibernate.Type explicitly

.Element("role", e => e.Type<NHibernate.Type.EnumStringType<Role>>())


来源:https://stackoverflow.com/questions/19597088/fluent-nhibernate-how-map-an-ilistenum-as-list-of-strings

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