views:

26

answers:

1

I'm currently working on an Web Application similar to Steamworks (if you don't know what it is, its a service for games to store Achievements, Stats etc).

The major problem I've run into in the development of this is the addition of new databases for games after the application has been deployed. I'm using LINQ-to-SQL to query the database appropriately, however the major issue is that, with additional databases that need querying being created after the application has been deployed, I'm not sure how to structure querying from different databases using LINQ.

Having to add a new DataContext, recompile and re=deploy the app is out of the question. I thought of doing this through a Plugin structure but it wont work, given the DataContext holds the references to column names etc.

Does anyone have any suggestion on how to overcome this? I can always go back to traditional SQL querying but I'd prefer not to. All column names and structure across every database will be identical, its just adding new databases and having the app use them is the major issue.

+1  A: 

If all column names and structures across every database are identical then maybe you can replace the connection string in the Constructor of the DataContext as shown below:

Old version:

public DatabaseDataContext() : base("...your connection string...", mappingSource)
{
    OnCreated();
}

New version:

public DatabaseDataContext() : base(Configuration.ConnectionString, mappingSource)
{
    OnCreated();
}

Then save all your connectionstring in an external file / database table and fetch the one you need or loop through them. :)

Hope I understood your question.

Dave
Thanks for the quick response, I'll give it a go. It seems to be what I'm looking for.
Matt Stafford