views:

221

answers:

3

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

A: 

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/

Paco
Thanks Paco. But is my approach a good way?
vikasde
A: 

Provide it a connection string. I know that sounds stupid, but it appears to be missing.

Woot4Moo
Its already there. I think its a misleading exception.
vikasde
Please provide a stack trace in full
Woot4Moo
A: 

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

Andrew Siemer