Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6196027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:34:18+00:00 2026-05-24T03:34:18+00:00

I have a scenario where there are multiple dbs that have the same schema

  • 0

I have a scenario where there are multiple dbs that have the same schema and clients can pick which database to query. Is there a way to include the database name when doing an oData query from silverlight so it can reuse the same services?

Lets say I have this query (see below) being executed at the client (silverlight/wp7), how do I get this query to run against the database that the user picked when they first launched the app?

private DataServiceCollection _employees;
private void LoadEmployees()
{
DataModelContainer dmc = new DataModelContainer(new Uri(“http://localhost:63832/DataService.svc”));
var query = (from e in dmc.Employees
where e.StartDate == BaseDate
select e);
_employees = new DataServiceCollection(dmc);
_employees.LoadCompleted += new EventHandler(_employees_LoadCompleted);
_employees.LoadAsync(query);
}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T03:34:19+00:00Added an answer on May 24, 2026 at 3:34 am

    Here is what I came up with: The AddQueryOption will add a value to the query string, in my case the key of the db that I want to run the query against.

    var query = (from e in dmc.Employees.AddQueryOption(“dbKey”, SelectedDB)
    where e.StartDate == BaseDate select e);
    _employees = new DataServiceCollection(dmc);
    _employees.LoadCompleted += new EventHandler(_employees_LoadCompleted);
    _employees.LoadAsync(query);
    }

    In the DataService class I overrride the CreateDataSource method and return a DataModelContainer with the correct connection string for the query
    protected override DataModelContainer CreateDataSource()
    {
    DataModelContainer dmc = new DataModelContainer(GetConnectionString());
    return dmc;
    }
    private string GetConnectionString()
    {
    string dbKey = HttpContext.Current.Request.Params[“dbKey”].ToString();
    string cnnKey = “DataModelContainer” + dbKey;
    return ConfigurationManager.ConnectionStrings[cnnKey].ToString();
    }

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a scenario. (Windows Forms, C#, .NET) There is a main form which
Scenario: We have a server where there are multiple ASP.NET websites hosted on it.
I have a scenario where I need to open multiple datacontexts which point to
Scenario: There are two entities say 'Books' and 'Book Reviews'. There can be multiple
I have a scenario where there are multiple mysql 4.x servers. These databases were
Scenario: I have several services that I want to be discovered by different clients.
I have a C program which has multiple worker threads. There is a main
I have a scenario in a system which I've tried to simplify as best
I have this scenario where I need data integrity in the physical database. For
we have this scenario: A server which contains needed data and client component which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.