无法确定列的类型:NHibernate.Mapping.Column(EnumType)

时间:2016-01-13 09:55:31

标签: c# nhibernate orm mapping

虽然已经多次询问过这个问题并且我一直关注strategy,但仍无济于事!

映射类:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns ="urn:nhibernate-mapping-2.2"
                   assembly ="Abc.Repository"
                   namespace ="Abc.Repository.Domain.Classes">

  <class name="SecPermission" table="SEC_PERMISSION">

    <id name="PerId" column="PER_ID" type="String" >
      <generator class="assigned" />
    </id>

    <property name="PerName" column="PER_NAME" not-null="true"/>

    <property name="PerParentId" column="PER_PARENT_ID" not-null="false"/>

    <property name="PerType" column="PERMISSION_TYPE" type="NHibernate.Type.EnumStringType`1                  [[Abc.Repository.Domain.Classes.SecPermission.permissionType, Abc.Repository]], NHibernate" not-null="false"/>

    <property name="CreatedOn" column="CREATED_ON" not-null="true"/>

    <property name="CreatedBy" column="CREATED_BY" not-null="true"/>

    <property name="UpdatedOn" column="UPDATED_ON" not-null="true"/>

    <property name="UpdatedBy" column="UPDATED_BY" not-null="true"/>

    <set name="pGroups" cascade="all-delete-orphan" inverse="true" >
      <key column="PER_ID" />
      <one-to-many class="SecGroupPermission" />
    </set>

  </class>
</hibernate-mapping>

.cs类

namespace Abc.Repository.Domain.Classes
{
    public class SecPermission : IEquatable<SecPermission>
    {
        #region Constructors

        public SecPermission()
        {

        }

        #endregion

        #region Enum
        public enum permissionType
        {
            Module ,
            Category ,
            Atomic ,
            Tab
        }

public virtual Abc.Repository.Domain.Classes.SecPermission.permissionType PerType { get; set; }
        }
    }

数据库表

CREATE TABLE [dbo].[SEC_PERMISSION](
    [PER_ID] [varchar](200) NOT NULL,
    [PER_PARENT_ID] [varchar](200) NULL,
    [PER_NAME] [nvarchar](200) NOT NULL,
    [PERMISSION_TYPE] [varchar](50) NULL,
    [CREATED_ON] [datetime] NOT NULL,
    [CREATED_BY] [nvarchar](100) NOT NULL,
    [UPDATED_ON] [datetime] NOT NULL,
    [UPDATED_BY] [nvarchar](100) NOT NULL,
 CONSTRAINT [PK_PERM] PRIMARY KEY CLUSTERED 
(
    [PER_ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

错误消息

无法确定以下类型: NHibernate.Type.EnumStringType`1 [[Abc.Repository.Domain.Classes.SecPermission.permissionType,Abc.Repository]],NHibernate,用于列: NHibernate.Mapping.Column(PERMISSION_TYPE)

1 个答案:

答案 0 :(得分:2)

类型写错了。因为它是内部类型,所以必须将+附加到包含类fullname

  

type =“NHibernate.Type.EnumStringType`1 [[Abc.Repository.Domain.Classes.SecPermission + permissionType,Abc.Repository]],NHibernate”