linq to sql - Specify ConnectionString for MVC DataContext globally -
i have mvc3 application allows user choose database want use on initial login. various connection strings available in web.config every datacontext use chosen connection.
i aware can supply parameter 1 instance of named datacontext this:
mydatacontext db = new mydatacontext(connectionstring); or can override oncreated event instances of named datacontext
public partial class mydatacontext { partial void oncreated() { connections connections = new connections(); this.connection.connectionstring = connections.getcurrentconnectionstring(); } } how instances of datacontexts throughout application?
Comments
Post a Comment