1
votes

We use two databases in our web-application. One is located in USA and one is in Canada. You should see only the data based on your country. Now I think there will be a problem when it comes to create the SessionFactory objects, because the entities were already created for USA. Now when nHibernate tries to create the factory for the CAN database, with the same entities, then I get the following error:

Could not find connection string setting (set connection.connection_string or connection.connection_string_name property)

How can I resolve this issue?

Update: Here is the stack trace:

at NHibernate.Connection.ConnectionProvider.Configure(IDictionary2 settings) at NHibernate.Connection.ConnectionProviderFactory.NewConnectionProvider(IDictionary2 settings) at NHibernate.Cfg.SettingsFactory.BuildSettings(IDictionary`2 properties) at NHibernate.Cfg.Configuration.BuildSettings() at NHibernate.Cfg.Configuration.BuildSessionFactory() at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory() in d:\Builds\FluentNH\src\FluentNHibernate\Cfg\FluentConfiguration.cs:line 93

2

2 Answers

0
votes

You can try NHibernate.Shards. It is still under development but probably working for you. http://nhcontrib.svn.sourceforge.net/svnroot/nhcontrib/trunk/src/NHibernate.Shards/

0
votes

Just an idea here, but given that your DAL is connecting to two different data sources on two different sets of infrastructure should you not spin up one instance of NHibernate session for CAN and one instance of NHibernate session for USA...and then merge the results after the query? Using one session to query two desperate data sources doesn't sound like the correct approach...even if it is physically possible. Separation of concerns should apply here I would think.

presentation -> service layer |-> projectName.dataAccess.usa.EntityRepository |-> projectName.dataAccess.can.EntityRepository