盼解:

解决方案 »

  1.   

    you need to use multiple SessionFactory
      

  2.   

    题目说得不好,因为我是在同一个程序中,有几个模块是用nhibernate的,但这几个模块又是连接不同的数据库的,这样就不能将配置信息放在web.config中了,需要另外放。但现在我不知道应该怎么放在一个单独的xml文件中,并动态读取。
    ---------------------------------------
    查网上有如下说法:>>>NH的配置有两种存放方式>>>存放在应用程序集的配置文件中, 对于Web应用程序则存放在Web.config中. 这种方式必须指定配置>>>节的处理程序(类); 
    >>>存放在一个单独的xml文件中, 使用这种方式我们必须在程序中显式的加载配置文件, 本文后面有详>>>细说明. 此方式有一个优点, 就是在多数据库的情况下, 可以用不同的配置文件与各个数据库进行>>>对应.但下文往往只有放在web.config中的做法的说明,没有存放在一个单独的xml文件中的说明,不知那位大大有单独存放在一个xml文件中,并显示加载配置文件的用法说明????我想将两个数据库的连接配置成两个不同的文件!!!
      

  3.   

    每个模块下放自己的NHibernate的配置文件也是可行的阿。
      

  4.   

    to : jonescheng
    不知道怎么放啊.....能不能详细说一下该怎么放?
      

  5.   

    Configuration config = new Configuration();
                IDictionary props = new Hashtable();props["hibernate.connection.provider"] = 
         "NHibernate.Connection.DriverConnectionProvider"; 
    props["hibernate.dialect" ] = "NHibernate.Dialect.MsSql2000Dialect"; 
    props["hibernate.connection.driver_class"] = 
         "NHibernate.Driver.SqlClientDriver" ;
    props["hibernate.connection.connection_string"] = 
         "Server=localhost;initial catalog=Northwind;Integrated Security=SSPI" ;foreach( DictionaryEntry de in props ) 
    {
        config.SetProperty( de.Key.ToString(), de.Value.ToString() );
    }
    http://www.codeproject.com/dotnet/nhibernatept1.aspor
    Configuration cfg = new Configuration()
        .AddXmlFile("Item.hbm.xml")
        .AddXmlFile("Bid.hbm.xml");....http://nhibernate.sourceforge.net/nh-docs/en/html/chunk/ch02.html
    then create your new SessionFactoryISessionFactory sessions = cfg.BuildSessionFactory();
      

  6.   

    终于找到了,谢谢思归大大!
    自己在google上找了很久都找不到,能请问一下大大是用什么关键字找到的吗?
      

  7.   

    "NHibernate configuration":http://www.google.com/search?hl=en&q=NHibernate+configuration&btnG=Google+Search