title: How to select the database from multiple connection strings based on name using web apis?
body: <p>How to select the database from multiple connection strings based on name using web apis and also how to use the same connection string for all the controllers rather than writing the database selection code in all the controllers. I'm writing the database selection code in all contrrols, I want to write it once and reuse it in all controllers. Using these controllers to connect to the database in xamarin forms</p>
  <p>Code for selecting the database based on clientname selection.</p>
  <pre><code> if (clientname.SelectedItem.Text == &quot;Client1&quot;)
          {
              connStr = (ConfigurationManager.ConnectionStrings[&quot;client_db1&quot;].ConnectionString);
          }
          else if (clientname.SelectedItem.Text == &quot;Client2&quot;)
          {
              connStr = (ConfigurationManager.ConnectionStrings[&quot;client_db2&quot;].ConnectionString);
          }
          else if (clientname.SelectedItem.Text == &quot;Client3&quot;)
          {
              connStr = (ConfigurationManager.ConnectionStrings[&quot;client_db3&quot;].ConnectionString);
          }
  </code></pre>
  <p>This is code which i want to reuse in all controllers,</p>
  <p>Please help
  Thanks</p>