Merge pull request #80 from aaronmell/master

Refactored DelegatingLocationSessionFactoryObject to support named connection strings
This commit is contained in:
Marko Lahma
2014-08-10 10:27:13 +03:00

View File

@@ -40,12 +40,20 @@ namespace Spring.Data.NHibernate
protected override void PostProcessConfiguration(Configuration config)
{
// called before NewSessionFactory
if (!config.Properties.ContainsKey(Environment.ConnectionString))
{
throw new System.ArgumentException("Must specify connection string");
}
var settings = ConfigurationManager.ConnectionStrings[config.Properties[NHibernate.Cfg.Environment.ConnectionStringName]];
if (settings != null)
{
config.Properties.Add(new KeyValuePair<string, string>(NHibernate.Cfg.Environment.ConnectionString, settings.ConnectionString));
}
// called before NewSessionFactory
if (!config.Properties.ContainsKey(NHibernate.Cfg.Environment.ConnectionString))
{
throw new System.ArgumentException("Must specify connection string. If connection_string_name is set to a value, make sure there exists a connection string with that name.");
}
}
}
}
}