LINQ vs. nHibernate
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 h开发者_运维百科ow well LINQ works with mono.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.
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.
There are 2 linq providers for NHibernate. They support all the database NHibernate supports
Remember that LinqToSql is really LinqToMsSqlServer - you're locked in if you take that route...
精彩评论