views:

167

answers:

6

I'd like to start an application that makes heavy use of a database, and is supposed to run on Windows under .NET as well as Mac/Linux under Mono.

Having done some research, I've realised that neither LINQ-to-SQL nor LINQ-to-Entities are production-ready in Mono at the moment (here and here). According to the former link, LINQ-to-SQL may at least make it into Mono 2.6, due some time in Nov 2009.

Mono also implements ADO.NET 2.0, as far as I can tell, although the test results are not looking great (assuming the page is up-to-date). Also, using raw ADO.NET is going to be very painful compared to LINQ.

Which database access API would you guys recommend in this situation?

+1  A: 

I'd recommend coding by interface here. One of the great things about .NET is that it makes heavy use of interfaces, so you could code against IDbConnection, IDbCommand and so on. This means that you can code your application in ADO.NET to be virtually database/provider agnostic.

Pete OHanlon
So you're recommending ADO.NET then?
romkyns
I am - you can use something like the excellent NHibernate (or Castle ActiveRecord) to take care of this for you.
Pete OHanlon
So a different implementation for Mono and for .NetFX?
James L
+1  A: 

Here is a link with the ADO.Net Data providers that Mono supports:

http://www.mono-project.com/Database%5FAccess

You do not say which database you will be using when running on Mono. Linq to SQL is only supported for MS SQL Server.

As others have said, it looks like nHibernate is the way to go.

Shiraz Bhaiji
Well... there is http://code2code.net/DB_Linq/ but it doesn't look quite production-ready. I'd be most happy with a database-agnostic approach.
romkyns
+3  A: 

If you want an ORM, use NHibernate. If you don't need an ORM, use ADO.NET.

Michael Maddox
Good answer. I want LINQ to SQL :) Not really an ORM, but not as much effort as ADO.NET. Shame I can't have that. NHibernate it is then.
romkyns
NHibernate is better than LinqToSql in almost every way, so it's not really a sacrifice. LinqToSql may appear "easy", but it's not.
Michael Maddox
+1  A: 

After much research I have discovered SubSonic, which looks to be much closer to the LINQ-to-SQL model than nHibernate. Just mentioning it since nobody else has. Not sure yet if this will be the final choice.

romkyns
While I haven't found my final solution in this .net/mono, I'm leaning to SubSonic from my reading.
kenny
SubSonic has much different features than NHibernate, which may be fine for you. If you don't think NHibernate looks like LinqToSql, maybe you haven't run across Castle ActiveRecord yet? Also, NHibernate supports Linq. It's not clear to me what appeals to you about LinqToSql?
Michael Maddox
It's very simple - I don't want an ORM. I just want to access the database in a way that's easier than raw SQL - mainly in allowing me to read results nicely.
romkyns
A: 

For the record, we settled on IQToolkit together with a custom tool to generate classes from a database. The result is more low-level than ActiveRecord-style approaches; essentially nothing more than adding strong typing and LINQ support on top of SQL.

romkyns