Helo,
here my question ;)
i want to define multipe session factories in just one config.xml. How can i choose in later code which sessionFactory should be used for session creation?
Every connection will be used in different dataprovider binaries so the usage in the special data provider should look like this:
Code:
// dataprovider for the first db:
_configuration = (new Configuration()).Configure();
// this is what i want ... or something similar
_sessionFactory = _configuration.BuildSessionFactory("firstdb");
_session = _sessionFactory.GetSession();
...
The config file:
Code:
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" >
<session-factory name="firstdb"> ... </session-factory>
<session-factory name="seconddb"> ... </session-factory>
</hibernate-configuration>
Or should i use multiple config files with different names an load them
with Configuration.Configure(string fileName);? But this would mean many files in the output directory which i would like to avoid.
In addition i would like to hide the connection information from the user, but as i know compiling as embedded ressource doesnt satisfy nhibernate. Some ideas how to realize it?
I looked for a programmitically way to initialize the sessionFactory in the dataprovider class (connection string, dialect etc) but the reference guide just tells how to define the mappings etc by code.
On this way i would have every database configured in the special dataprovider and additionally hidden the connection information from the user.
Greetings
Adam