Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/338.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 没有类错误的持久化程序_C#_Asp.net_Nhibernate - Fatal编程技术网

C# 没有类错误的持久化程序

C# 没有类错误的持久化程序,c#,asp.net,nhibernate,C#,Asp.net,Nhibernate,当我运行应用程序时,我得到“Test.Student没有持久器”错误 我是Nhibernate映射的新手,我无法理解这一点 我怎样才能解决??plz帮助 NHibernate配置部件 App.config <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="hibernate-configuration" type="

当我运行应用程序时,我得到“Test.Student没有持久器”错误 我是Nhibernate映射的新手,我无法理解这一点
我怎样才能解决??plz帮助

NHibernate配置部件

App.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
 <configSections>
  <section name="hibernate-configuration"
    type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" />
</configSections>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
  <property name="connection.provider">
    NHibernate.Connection.DriverConnectionProvider
  </property>
  <property name="connection.driver_class">
    NHibernate.Driver.SqlClientDriver
  </property>
  <property name="connection.connection_string">
    Server=(local);database=Student;Integrated Security=SSPI;
  </property>
  <property name="dialect">
    NHibernate.Dialect.MsSql2005Dialect
  </property>
  <!--<property name="proxyfactory.factory_class">
    NHibernate.Bytecode.DefaultProxyFactoryFactory, NHibernates
  </property>-->
  <property name="show_sql">
    false
  </property>
</session-factory>
}

映射部分

Student.hbm.xml

  <?xml version="1.0" encoding="utf-8" ?>
      <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-import="true">
      <class name="Test.Student" table="Info" lazy="true">
     <id name="Id" type="int" column="Id">
       <generator class="native" />
    </id>

       <property name="Fname" column ="Fname"/>
<property name="Lname" column="Lname"/>
<property name="Address" column="Address"/>
<property name="Institution" column="Institution"/>

<!-- We don't have to specify a column name if its the same 
     as the variable name -->


您需要在
app.config
文件中添加映射程序集名称,如上所述

false

如果没有,请确保将XML文件标记为
嵌入式资源

是否将XML文件生成操作设置为
嵌入式资源
?是的,但没有任何区别
  <?xml version="1.0" encoding="utf-8" ?>
      <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-import="true">
      <class name="Test.Student" table="Info" lazy="true">
     <id name="Id" type="int" column="Id">
       <generator class="native" />
    </id>

       <property name="Fname" column ="Fname"/>
<property name="Lname" column="Lname"/>
<property name="Address" column="Address"/>
<property name="Institution" column="Institution"/>

<!-- We don't have to specify a column name if its the same 
     as the variable name -->
   <property name="show_sql">false</property>
   <mapping assembly="Test"/>  <!-- Here -->
</session-factory>