Hello, I'm having some problems with this feature, maybe someone can help.
Here's my setup: I'm using Nettiers 2.2 and a Domain Model, with EntLib 3.1. I am just generating the data access, no web service or web interfaces.
I have a single connection string in the app.config, and in my code I can successfully change the connection string dynamically:
ConnectionScope.Current.ConnectionStringKey = "mySecondConnectionString";
ConnectionScope.Current.DynamicConnectionString = "Data Source=localhost;Initial Catalog=MyDatabase;Integrated Security=True";
MyDataAccessCall();
Problems are:
1) how do I get back to the default database (the one configured in the app.config file)? I tried setting the ConnectionStringKey to the name of the CS Key in app.config, and it doesn't work. This seems to be related to the following:
2) how do I change to another database after having done a data access with a dynamic connection string?
It seems that from the moment I change the connection scope and do a data access, the data source is locked. So if I do:
ConnectionScope.Current.ConnectionStringKey = "mySecondConnectionString";
ConnectionScope.Current.DynamicConnectionString = "Data Source=localhost;Initial Catalog=MyDatabase;Integrated Security=True";
MyDataAccessCall();
ConnectionScope.Current.ConnectionStringKey = "myThirdConnectionString";
ConnectionScope.Current.DynamicConnectionString = "Data Source=localhost;Initial Catalog=MyThirdDatabase;Integrated Security=True";
MyDataAccessCall();
The second "MyDataAccessCall()" still gets data from MyDatabase, and not MyThirdDatabase.
Any ideas?
Note: "MyDataAccessCall()" just includes a GetAll() call such as this:
TList<MyNS.Domain.MyEntity> partners = MyNS.Domain.MyEntity.GetAll();
Any help is greatly welcome. Thanks in advance.
João Pedro Martins