1

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?

Roman Starkov
  • 59,298
  • 38
  • 251
  • 324

5 Answers5

3

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

Michael Maddox
  • 12,331
  • 5
  • 38
  • 40
  • 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. – Roman Starkov Oct 12 '09 at 09:02
  • 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 Oct 12 '09 at 09:43
1

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
  • 9,086
  • 2
  • 29
  • 28
1

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

http://www.mono-project.com/Database_Access

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
  • 64,065
  • 34
  • 143
  • 252
  • 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. – Roman Starkov Oct 11 '09 at 22:12
1

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.

Roman Starkov
  • 59,298
  • 38
  • 251
  • 324
  • While I haven't found my final solution in this .net/mono, I'm leaning to SubSonic from my reading. – kenny Oct 12 '09 at 14:37
  • 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 Oct 12 '09 at 15:39
  • 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. – Roman Starkov Oct 13 '09 at 12:09
0

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.

Roman Starkov
  • 59,298
  • 38
  • 251
  • 324