错误:
“/”应用程序中的服务器错误。
--------------------------------------------------------------------------------in expected: <end-of-text> (possibly an invalid or unmapped class name was used in the query) [from Customer] 
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: NHibernate.QueryException: in expected: <end-of-text> (possibly an invalid or unmapped class name was used in the query) [from Customer]源错误: 
行 15:         {
行 16:             //string hql = "from Customer";
行 17:             IQuery q = Db.Session.CreateQuery("from Customer");
行 18:             //q.SetCacheable(true);
行 19:             //q.SetCacheRegion("Customer");

 
DTO.Domain代码:
using System;
using System.Collections.Generic;
using System.Text;namespace SK.DTO.Domain
{
    [Serializable]
    public class Customer
    {
        protected string _id;
        protected string _user;
        protected string _email;
        public virtual string Id
        {
            get { return _id; }
            set { _id = value; }
        }
        public virtual string User
        {
            get { return _user; }
            set { _user = value; }
        }
        public virtual string Email
        {
            get { return _email; }
            set { _email = value; }
        }
        public Customer()
        {
           _id = String.Empty;
           _user = String.Empty;
           _email = String.Empty;
        }
    }
}DTO.XML代码:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="SK.DTO.Domain" assembly="SK.DTO.Domain">
  <class name="Customer" table="customers" proxy="Customer">
    <cache usage="read-write" />
    <id name="Id" column="customer_id" type="String" not-null="true" length="4" >
    <generator class="assigned"/>
    </id>
    <property name="User"  column="customer_user"   type="String"  length="20"/>
    <property name="Email" column="customer_email"  type="String"  length="20"/>
  </class>
</hibernate-mapping>

解决方案 »

  1.   

    右击解决方案里的DTO.XML映射文件-属性-生成操作-嵌入的资源。再试试。
      

  2.   

    Web.Config里面需要配置NHibernate信息的,配置如下:<?xml version="1.0"?>
    <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
    <configSections>
    <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
    <session-factory>
    <property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property>
    <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
    <property name="connection.connection_string">Server=ServerName;initial catalog=DataBaseName;user=sa;password=password</property>
    <property name="show_sql">true</property>
    <property name="hbm2ddl.auto">none</property>
    <mapping assembly="Model"/> </session-factory>
    </hibernate-configuration>
    </configSections>
      

  3.   


    配置了NHibernate。config
    配置如下:
    <?xml version="1.0" encoding="utf-8" ?>
    <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
      <session-factory>
        <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
        <property name="connection.connection_string_name">Connection String</property>
        <property name="connection.connection_string">Server=localhost;initial catalog=lhy;Integrated Security=SSPI</property>
        <property name="adonet.batch_size">10</property>
        <property name="show_sql">true</property>
        <property name="dialect">NHibernate.Dialect.MsSql2000Dialect</property>
        <property name="use_outer_join">true</property>
        <property name="command_timeout">300</property>
        <property name="query.substitutions">true 1,false 0,yes 'Y',no 'N'</property>    <mapping assembly="SK.DTO.Domain" />
      </session-factory>
    </hibernate-configuration>  
      

  4.   

    把DTO.xml改成Customer.hbm.xml呢?