Using LINQ to connect with multiple databases
I am developing an ASP.NET application in which I need to provide suppo开发者_运维问答rt for two databases, MySql and MS SQL Server 2005 and 2008 (one database will be used at a time).
How will I configure the ASP.NET app to connect with different databases without reinstalling the app (i.e. using configuration)?
How will I configure LINQ?
Shouldn't I use NHibernate?
Use basic Linq to SQL structures (nothing database specific) and by just changing the connection string should do the trick. Linq expression trees are transformed to SQL by Linq enabled drivers (i.e. they know how to handle the expression tree).
Here is better way of doing it: Multiple database support with Entity Framework.
精彩评论