【发布时间】:2012-02-15 03:11:07
【问题描述】:
我开始使用 nHibernate 代码映射,但我一直在映射一组枚举。
(注意,这个问题类似于Mapping collection of enum in NHibernate,但不同之处在于我想使用代码映射进行映射。)
我有一个实体“角色”,它有一个“权限”集合,其中权限是一个枚举。
旧的 xml 映射是:
<set name="Permissions" cascade="none" table="role_permissions">
<key column="role_id" />
<element column="permission_id" type="MyApp.Permissions, MyApp" />
</set>
我正在尝试在这样的代码中进行映射,但出现异常:
Set(x => x.PermissionCollection, m => { },
r => r.Element(e =>
{
e.Column("permission_id");
e.Type<Permissions>();
}));
抛出的异常是
Expected type implementing IUserType or IType.
Parameter name: persistentType
【问题讨论】:
标签: nhibernate nhibernate-mapping