Handling different databases with LINQ based off the user which is current logged in?


I've been given the task of creating a site that will allow our various large clients to log into our website and click on our various pages to view analytics data based on their sales.

Does anyone have any idea about the best way to handle multiple databases based off the user? Lets say we have 3 big name clients, the design decision has been made each big client has their own database.

If a user from clientA logs into our system they should see the analytics for their company, and the model should be pulling down from clientA's data context. Likewise, if someone logs in and they are associated with clientB in the database then they need to have their data pulled from that data context.

If I can, I would like to have one Data Access Layer class written in LINQ and have some way of passing in the associated DataContext with that user when they login. Can anyone think of an appropriate or clean way to do this?


If the schema's are the same for all databases, then it's very simple. The datacontext has an overload which takes a connection string. Simply store the various connection strings in some centralized location (database, XML, resource, whatever) and then just create one datacontext with that connection string which you can then use regardless of who's connected.

By : BFree

You should try using nohup and running it in the background:

nohup sleep 3600 &
By : paxdiablo

Assuming that you have a program running in the foreground, press ctrl-Z, then:

[1]+  Stopped                 myprogram
$ disown -h %1
$ bg 1
[1]+ myprogram &
$ logout

If there is only one job, then you don't need to specify the job number. Just use disown -h and bg.

Explanation of the above steps:

You press ctrl-Z. The system suspends the running program, displays a job number and a "Stopped" message and returns you to a bash prompt.

You type the disown -h %1 command (here, I've used a 1, but you'd use the job number that was displayed in the Stopped message) which marks the job so it ignores the SIGHUP signal (it will not be stopped by logging out).

Next, type the bg command using the same job number; this resumes the running of the program in the background and a message is displayed confirming that.

You can now log out and it will continue running..

This video can help you solving your question :)
By: admin