2010-04-05 3 views
0

저는 NHibernate에서 새롭기 때문에 기능을 어디에 사용해야하는지 혼란 스럽습니다.클래스 라이브러리가있는 웹 폼 nhibernate

나는 다음과 같은 솔루션을

1) MyProject.Web (웹 양식 응용 프로그램)

2) MyProject.Domain (클래스 라이브러리)

  • nhibernate.config
  • 제품이있다. hbm.xml

맞습니다. 다음 메서드를 IHttpModule에 넣을 수 있습니까? (나는 글로벌 ASP를 사용할 수 없다. 실행중인 CMS에 의해 사용된다.)

어디에서 connectionString이 살아야 하는가?

HttpModule을 웹에서 응용 프로그램을

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(); 
} 

nhibernate.config

<?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> 

답변

0

ConnectionString을 어느 당신의 hibernate.cfg.xml 파일에 살아야 또는 web.config 파일을 형성 ...

훌륭한 가이드 장소 시작을 통해 당신은 nhibernate.info wikisYour first Nhibernate based application입니다 ... 확실히 알아 냈을 때 (여전히 나를 돕습니다!) ... 시작과 관련하여 많은 질문이있는 것처럼 보입니다.