NHibernate сообщение об ошибке загрузки - PullRequest
0 голосов
/ 17 сентября 2010

У меня появляется сообщение об ошибке с MappingNHibernateException:

{"Не удалось скомпилировать документ сопоставления: Infrastructure.DataAccess.Mappings.Post.hbm.xml"}

Could not find the dialect in the configuration

со стороны

  Configuration configuration = new Configuration()
                .AddAssembly("Infrastructure");
                _sessionFactory = configuration.BuildSessionFactory();

Что не так?


hibernate.cfg.xml

    <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="dialect">NHibernate.Dialect.MsSql2000Dialect</property>
    <property name="connection.connection_string">Server=localhost\SQLServer2005;database=NHibernate101;Integrated Security=True;</property>
    <property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
    <mapping assembly="Infrastructure"></mapping>
  </session-factory>
</hibernate-configuration>

1 Ответ

0 голосов
/ 17 сентября 2010

Попробуй это.В файле app.config:

<configuration>
  <configSections>
    <section
        name="hibernate-configuration"
        type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate"
        />
  </configSections>

  <!-- Replace with your values -->
  <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
    <session-factory>
      <property name="dialect">NHibernate.Dialect.SQLiteDialect</property>
      <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
      <property name="connection.connection_string">Data Source=data.db3;Version=3</property>
      <property name="connection.driver_class">NHibernate.Driver.SQLite20Driver, NHibernate</property>
      <property name="show_sql">true</property>
      <property name="adonet.batch_size">0</property>
      <property name="default_batch_fetch_size">0</property>

      <mapping assembly="Infrastructure" />
    </session-factory>
  </hibernate-configuration>

</configuration>

И в вашем коде:

var cfg = new Configuration().Configure();
var factory = cfg.BuildSessionFactory();
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...