I have a solution with two MVC 3 application sharing the same DAL libaray. Each application is pointing to a different db and their connection string is stored in their respective web.config file.
What would be the best approach to pass their connection string to the DAL?
From MVC controller:
string _connectionString = WebConfigurationManager.ConnectionStrings["NexGenContext"].ToString();
// Changes???
QuestionDAL qd = new QuestionDAL();
var agency = qd.SearchAgencies(ori, name)
DAL code:
public IEnumerable<AgencyTerm> SearchAgencies(string ori, string name)
{
log.Debug("Executing: SearchAgencies(string ori, string name)");
List<AgencyTerm> agencies = new List<AgencyTerm>();
using (var conn = new SqlConnection(_connectionString))
{
var com = new SqlCommand();
com.Connection = conn;
com.CommandType = CommandType.StoredProcedure;
... etc....
//Add constructor
public QuestionDAL(string connectionString)
{
_connectionString = connectionString;
}