2

Question: Until now, I didn't know LINQ was an ORM tool. I always saw it as some new kind of SQL query language. So I very recently started using nHibernate.

So my question:
What would be the advantages and disadvantages of LINQ in comparison to nHibernate?

As far as I found out, the differences are that LINQ requires .NET > 2.0 (unless you hack it, which is unsafe and illegal), while nHibernate works with >=2.0.
And that for LINQ, you need to have a vendor/3rd party LINQ provider dll if you don't use MS-SQL.
What I don't know in particular is which one is faster/easier, and whether there are LINQ providers for all databases supported by nHibernate, and how well LINQ works with mono.

Stefan Steiger
  • 78,642
  • 66
  • 377
  • 442

4 Answers4

6

Linq isn't an ORM tool. Linq2Sql and the Entity framework are Microsoft ORM tools using Linq. I found this article comparing NHibernate to Entity Framework 4,0 quite enlightening.

To summarise: NHibernate, is long established and tested and Fluent is a joy to use. Unfortunately NHibernate suffers in the documentation dept, but is OS so you can dig into the code. EF 1.0 was horrendous, but 4.0 is much better. It's a MS product so is heavily evangelised, supported and there are many examples out on the web. 4.0 is still beta for now.

burnside
  • 2,551
  • 23
  • 20
3

LINQ is not an ORM. LINQ is just a query technology/library with special syntax in C# and LINQ and NHibernate are complementary technologies. There is even LINQ2NHiernate.

LINQ2SQL is an ORM. With respect to speed, I would not worry too much about it unless you are making stock exchange software or something like that, where milliseconds are absolutely crucial. I believe even StackOverflow runs on LINQ2SQL, or did at some point, but I might be wrong.

Rune
  • 8,340
  • 3
  • 34
  • 47
  • OK, so with LINQ I meant LINQ2SQL ;-)) I read somewhere else they are switching from LINQ to nHibernate for performance reasons. So I'm not sure it's not important. – Stefan Steiger Mar 02 '10 at 11:27
1

There are 2 linq providers for NHibernate. They support all the database NHibernate supports

Paco
  • 8,335
  • 3
  • 30
  • 41
1

Remember that LinqToSql is really LinqToMsSqlServer - you're locked in if you take that route...

UpTheCreek
  • 31,444
  • 34
  • 152
  • 221