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.

- 78,642
- 66
- 377
- 442
-
Just to clarify, LINQ was part of the .Net 3 framework. – Neil Knight Mar 02 '10 at 11:12
-
7Ok, you're busy confusing to things "Linq" which is the query language and "Linq to SQL" which is an ORM. You can use Linq to query NHibernate if you choose... – Murph Mar 02 '10 at 11:21
-
I think I'm going to stay with nHibernate. – Stefan Steiger Mar 02 '10 at 11:30
-
3http://stackoverflow.com/questions/26971/nhibernate-vs-linq-to-sql – Mauricio Scheffer Mar 02 '10 at 12:17
4 Answers
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.

- 2,551
- 23
- 20
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.

- 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
There are 2 linq providers for NHibernate. They support all the database NHibernate supports

- 8,335
- 3
- 30
- 41
Remember that LinqToSql is really LinqToMsSqlServer - you're locked in if you take that route...

- 31,444
- 34
- 152
- 221