Monday, July 14, 2008 7:19 AMI have a situation wherein my web application will need to access multiple databases - all with the same schema. Does this mean that I have to create a (LINQ to SQL classes mapped to relational objects) DBML file for each of them? Or should in my controllers, I would need to wrap every call with something to bind to my user controls (DataGrid)?
public DataTable JustLoadCustomers()
DataTable dt=new DataTable();
using (StarsMainDataContext db = new StarsMainDataContext(connString))
System.Collections.Generic.IEnumerable<DataRow> qry = from cust in db.Customers.AsEnumerable()
// Create a table from the query.
DataTable boundTable = query.CopyToDataTable<DataRow>();
Will there be any performance penalties? Does this LINQ to SQL classes need Full trust when deployed to hosted sites?
Monday, July 14, 2008 7:38 PMI'm not the best person with LINQ yet but if i'm not wrong, the datacontext object is in charge of the connection. If you are using manually the datacontext object you can just change the connection property of it at runtime and voila...
If you are using it in a control as a binding then my guess is that you have to override one or several functions of the datacontext class. There are tons and i wouldn't be surprised to find one that governs the connection properties. Overloading such a function can then allow you to look in a global object or in the session variables to find which server/database to connect to.