C# 带有类库的nhibernate webforms

C# 带有类库的nhibernate webforms,c#,nhibernate,C#,Nhibernate,我对NHibernate非常陌生,对功能应该放在哪里有点困惑 我有以下的解决方案 1 MyProject.Web表单应用程序 2 MyProject.Domain类库 nhibernate.config product.hbm.xml 那么,我应该将以下方法放在IHTTP模块中是否正确?我不能使用全局asax,因为我正在运行的CMS正在使用它 连接字符串应该位于哪里 web窗体应用程序中的HTTPModule nhibernate.config connectionString应该位于hiber

我对NHibernate非常陌生,对功能应该放在哪里有点困惑

我有以下的解决方案

1 MyProject.Web表单应用程序

2 MyProject.Domain类库

nhibernate.config product.hbm.xml 那么,我应该将以下方法放在IHTTP模块中是否正确?我不能使用全局asax,因为我正在运行的CMS正在使用它

连接字符串应该位于哪里

web窗体应用程序中的HTTPModule

nhibernate.config


connectionString应该位于hibernate.cfg.xml文件或web.config文件中

一个伟大的地方,指导你通过开始是从…当然帮助了我,当我发现它仍然帮助我!。。。因为你似乎有一大堆关于开始的问题

 private static ISessionFactory CreateSessionFactory()
 {
     var cfg = new Configuration().Configure(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "nhibernate.config"));
     cfg.SetProperty(NHibernate.Cfg.Environment.ConnectionStringName, System.Environment.MachineName);
     NHibernateProfiler.Initialize();

     return cfg.BuildSessionFactory();
}
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
    <session-factory name="RBL.Domain">
        <property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property>  
        <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
        <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
        <property name="adonet.batch_size">16</property>
        <property name="current_session_context_class">web</property>
        <property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
        <mapping assembly="RBL.Domain"/>
    </session-factory>
</hibernate-configuration>