Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Never done this before but have some idea to achive this. In my project i have references to 2 database. PostgreSQL and Oracle. In my application i have the several provider classes that implement the database access and use Executor classes for this. To create the instance of this executors i need to pass the connection string with IP(in local network) of my databases. The connection string i recive from Web.config file like</p> <pre><code> //Here is the connection strings with IP, Login, and DBname from web.config You need to configure it dynamicaly private string PostgreSQLConnection = WebConfigurationManager.ConnectionStrings["PostgreSQLConnection"].ConnectionString; private string OracleConnection = WebConfigurationManager.ConnectionStrings["OracleConnection"].ConnectionString; using (PostgreSQLExecutor executor = new PostgreSQLExecutor(PostgreSQLConnection)) { executor.ExecuteQuery(@"query"); } using (OracleSQLExecutor executor = new OracleSQLExecutor(OracleConnection)) { executor.ExecuteQuery(@"query"); } </code></pre> <p>There is no problem to pass any string as connection string. I dont know what database access libary your application use, but im sure it hase the class witch alow you to configure you session like in my example. So, i think you just <strong>need to find your database config class</strong> and implement dynamic configuration logic. Better would be to create the route with database section like this.</p> <pre><code> routes.MapRoute( name: "Default", url: "{databaseSection}/{controller}/{action}/{id}", defaults: new { databaseSection = "sectionName1", controller = "Home", action = "Index", id = UrlParameter.Optional }, constraints: new { databaseSection = "sectionName1|sectionName2" } ); </code></pre> <p>so if application switch the url to site.com/sectionName2/home/index you can retrive the section name and configure you database acces as global behavior. For example in global.asax Application_BeginRequest event </p> <pre><code> protected void Application_BeginRequest(object sender, EventArgs e) { string section = Request.RequestContext.RouteData.Values["databaseSection"].ToString(); if(section == sectionName2) { do some stuff to configure your database session } else { default behavior } } </code></pre> <p>Alternatively you can use the cookie for this. Hope it helps. And sorry for my english /:</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload