HNibernate在多帐套应用中的数据连接
习惯用xml文件配置数据连接?我也是的。在多帐套应用中,我们希望由程序来决定连接数据库。HNibernate当然也可以,同时打开几个连接也是可以的。
以下是修改Config的代码:
Configuration cfg = new Configuration();
cfg.SetProperty("hibernate.dialect","NHibernate.Dialect.MsSql2000Dialect");
cfg.SetProperty("hibernate.connection.driver_class","NHibernate.Driver.SqlClientDriver");
cfg.SetProperty("hibernate.connection.connection_string","Server=localhost;initial catalog=nhibernate;Integrated Security=SSPI");
cfg.SetProperty("hibernate.dialect","NHibernate.Dialect.MsSql2000Dialect");
cfg.SetProperty("hibernate.connection.driver_class","NHibernate.Driver.SqlClientDriver");
cfg.SetProperty("hibernate.connection.connection_string","Server=localhost;initial catalog=nhibernate;Integrated Security=SSPI");