I have an application that uses Structuremap for DI for both my business and DAL layer. Up to this point, I have had a single DAL per environment that I have been working on. So I would grab it from the config and use that value for all my connections. An example of this is.
using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["Database"].ToString()))
{
//Do a call to db here.
}
I am calling this method using structure map as follows.
ObjectFactory.GetInstance<IDALManager>().MethodName();
Now I have a new feature where I want to allow the users to make change in a dev environment and then push a button to elevate it to test or prod environment. Therefore my connectionstring for the DAL manager will need to be able to change. I also would like to keep all the connection string access in the DAL and not in the other layers. I am looking for advice on how to do this or what design patterns to look into for this.
UPDATED INFORMATION The user will determine which connection string needs to be used. For example, they will be moving data from dev to test, they will select a source and a destination.
string source = \\user selection from combobox.
if (source == "DEV")
{
//Instantiate dev instance of manager
}
if (source == "TEST")
{
//Instantiate Test Instance of manager.
}