views:

4752

answers:

7

There are numerous libraries providing Linq capabilities to C# code interacting with a MySql database. Which one of them is the most stable and usable on Mono?

Background (mostly irrelevant): I have a simple C# (.Net 2.0) program updating values in a MySql database. It is executed nightly via a cron job and runs on a Pentium 3 450Mhz, Linux + Mono. I want to rewrite it using Linq (.Net 3.5) mostly as an exercise (I have not yet used Linq).

A: 

at this time you cannot use linq to sql, you might look into a third party linq mysql provider or linq to entities. linq to sql only works for sql server databases.

John Boker
+4  A: 

The only (free) linq provider for MySql is DbLinq, and I believe it is a long way from production-ready.

There is also MyDirect.Net which is commercial, but I have heard mixed reviews of it's capability.

I've read that MySql will be implementing the Linq to Entities API for the 5.3 version of the .net connector, but I don't know if there's even a timeline for that. In fact, MySql has been totally silent about Entity Framework support for months.


Addendum: The latest release of the MySql Connector/Net 6.0 has support for the EF according to the release notes. I have no idea how stable/useful this is, so I'd love to hear from anybody who have tried it.

Adam Lassek
A: 

LINQ to SQL is simply a ORM layer leveraging the power of expressions to make it easy to construct queries in your code.

If you are just calling adhoc queries for your tool, there is little need to use LINQ, it just adds an extra layer of abstraction to your code.

FlySwat
+2  A: 

According to the Mono roadmap I'm not sure if Linq is available for mono?

At least some of Linq might be available in the very latest release, but Linq to DB is listed for Mono 2.4 (Feb 2009)

Douglas Leeder
+2  A: 

Not sure about Mono, but I just started using LightSpeed and that supports LINQ-to-MySQL.

kaneuniversal
LightSpeed now supports Mono (http://www.mindscape.co.nz/blog/index.php/2009/02/12/lightspeed-and-mono/).
itowlson
A: 

I have tried the tutorial at http://www.primaryobjects.com/CMS/Article100.aspx. This uses dblinq/dbmetal to generate the data context class and classes for each table.

The code failed at the first attempt with an unhandled exception (MySql.Data.Types.MySqlConversionException: Unable to convert MySQL date/time value to System.DateTime"). Googling revealed this should be easily solved by appending "Allow Zero Datetime=True;" to the connection string. Unfortionately this turned out not to solve my problem. Thinking the MySQL .Net Connector was to blame I executed the SQL generated by dblinq without the linq2sql intermediary layer using the MySQL Connector. This time no exception occured. Tables which do not have a date column did work with DbLinq. So, from my experiment I agree with Adam, DbLinq is a long way from production ready.

JC Denton
A: 

please try ALinq, http://www.alinq.org

ansi