views:

58

answers:

2

I have project creating with WPF and for database O/RM using LINQ to SQL, when i finish my project some people want to use MySQL as database, so can I change my Linq to MySQL without change any source code (maybe just change the connection string)

Regards

+2  A: 

No you can't. LINQ to SQL as an O/RM tool is developed* solely for use with a SQL Server database and Microsoft will not add multi-database support in the future. When you want this and need descent LINQ support, you'd be better off with Microsoft Entity Framework.


*The C# team did actually design LINQ to SQL to be multi database. You can still see this design when you look at th System.Data.Linq assembly within Reflector. For 'some' reasons however (read: marketing) Microsoft decided not to allow multi-database support upon LINQ to SQL. The provider model that LINQ to SQL uses was internalized. While in theory it still is possible to create an alternative provider for other databases when your application runs in full trust; it is so hard and painful to do so, that I've never seen anyone even try it. Like I said, when multi-vendor support is a requirement for your application, you should use a O/RM tool that is designed especially for this.

Steven
A: 

You'll need 3. party support. http://www.devart.com sells DB drivers for various databases and includes Entity and LINQ to SQL support. There's also http://code.google.com/p/dblinq2007/ and http://www.alinq.org/

nos