views:

214

answers:

2

I'd like to have a single configuration file and then when I'm creating a session change the hibernate-configuration->session-factory->connection.connection_string property to what I want it to be programmatically? Is it possible?

UPDATE:

I believe I may be able to do this like this

Configuration cfg = new Configuration();
cfg.Configure(sessionFactoryConfigPath);

cfg.Properties["connection.connection_string"] = ...

What I would wonder than, if that is ok, Is this a bad way to handle connecting to a different database for each session? if so why etc. I'd also like to know if/how you can open an nhibernate session with a .net connection object?

+2  A: 

I think it is better to use different configuration files per each data base just becouse you will be able to switch dialects very esasy.

Sly
Thats the way I would like to do it but because we have a different DAL for a seperate part of the project we want to be able to read the connection from the same place. Its office politics **** . I've found also I can use a single config file and open a session with a standard sql connection.Again I'm worried slightly about performance implications?