流畅的NHibernate - 如何映射IList&Enum>作为字符串列表 [英] Fluent NHibernate - How map an IList<Enum> as list of strings
本文介绍了流畅的NHibernate - 如何映射IList&Enum>作为字符串列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个课程,有 IList< Role>角色
作为由以下代码映射的属性:
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()
但是将角色
映射到 int
的列,但是我希望将其映射到 string
。
but this maps roles
to a column of int
but I want it to be mapped to a column of string
.
推荐答案
使用override来明确指定NHibernate.Type
use the override to specify the NHibernate.Type explicitly
.Element("role", e => e.Type<NHibernate.Type.EnumStringType<Role>>())
这篇关于流畅的NHibernate - 如何映射IList&Enum>作为字符串列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文