<p>If starting a new project what would you use for your ORM NHibernate or LINQ and why.  What are the pros and cons of each.</p>

<p>edit: LINQ to SQL not just LINQ (thanks @Jon Limjap)</p>

[{'answer_id': 53421, 'author': 'Jon Limjap', 'author_id': 372, 'author_profile': 'https://Stackoverflow.com/users/372', 'pm_score': 3, 'selected': False, 'text': '<p>Errr... there\'s <a href="http://www.ayende.com/Blog/archive/2007/03/17/Implementing-Linq-for-NHibernate-A-How-To-Guide--Part.aspx" rel="nofollow noreferrer">LINQ for NHibernate</a>.</p>\n\n<p>Perhaps what you mean is which to use:</p>\n\n<ul>\n<li>LINQ to SQL</li>\n<li>NHibernate</li>\n</ul>\n\n<p>I prefer NHibernate. </p>\n\n<p>LINQ to SQL is fairly lightweight, but it\'s a little bit more tightly coupled to your data structure, as opposed to NHibernate which is pretty flexible in terms of the types of object definitions that can be mapped to your table structures.</p>\n\n<p>Of course that\'s not to say that LINQ to SQL has no uses: this very website uses it. I believe that it\'s quite useful to get up and running in small applications where the database schema is not as massive.</p>\n'}, {'answer_id': 53424, 'author': 'David Pokluda', 'author_id': 223, 'author_profile': 'https://Stackoverflow.com/users/223', 'pm_score': 5, 'selected': True, 'text': '<p>I have asked myself a very similar question except that instead of NHibernate I was thinking about WilsonORM which I have consider pretty nice.</p>\n\n<p>It seems to me that there are many important differences.</p>\n\n<p>LINQ:</p>\n\n<ul>\n<li>is not a complete ORM tool (you can get there with some additional libraries like the latest Entity framework - I personally consider the architecture of this latest technology from MS to be about 10 years old when compared with other ORM frameworks)</li>\n<li>is primarily querying "language" supporting intellisense (compiler will check the syntax of your query)</li>\n<li>is primarily used with Microsoft SQL Server</li>\n<li>is closed source</li>\n</ul>\n\n<p>NHibernate:</p>\n\n<ul>\n<li>is ORM tool </li>\n<li>has pretty limited querying language without intellisense</li>\n<li>can be used with almost any DBMS for which you have a DB provider</li>\n<li>is open source</li>\n</ul>\n\n<p>It really depends. If you develop a Rich (Windows) desktop application where you need to construct objects, work with them and at the end persist their changes, then I would recommend ORM framework like NHibernate.</p>\n\n<p>If you develop a Web application that usually just query data and only occasionally writes some data back to the DB then I would recommend good querying language like Linq.</p>\n\n<p>So as always, it depends. :-)</p>\n'}, {'answer_id': 4337205, 'author': 'JackD', 'author_id': 360115, 'author_profile': 'https://Stackoverflow.com/users/360115', 'pm_score': 2, 'selected': False, 'text': '<p>Start with NHibernate is a bad idea. It shows a good performance only with ably settings. Try to use EFv4 for large projects and L2S (maybe 3rd-part products) for small and medium size. These products are more convenient and flexible than NHibernate and allow you to start quickly.</p>\n'}, {'answer_id': 6122409, 'author': 'Firo', 'author_id': 671619, 'author_profile': 'https://Stackoverflow.com/users/671619', 'pm_score': 2, 'selected': False, 'text': '<p>not a complete list</p>\n\n<p>LinqToSQL\nPro:</p>\n\n<ul>\n<li>better tool support</li>\n<li>good linq provider</li>\n<li>easy to start with when db-schema == classes  - </li>\n</ul>\n\n<p>Con:</p>\n\n<ul>\n<li>not flexible (ie db-schema != classes)</li>\n<li>only supports MS SQL Server</li>\n<li>no cascading (save, update ... doesnt cascade to referenced objects)</li>\n</ul>\n\n<p>NHibernate\nPro:</p>\n\n<ul>\n<li>a lot rdbms supported ootb</li>\n<li>feature rich</li>\n<li>very flexible for almost all corner cases</li>\n<li>open source</li>\n</ul>\n\n<p>Con:</p>\n\n<ul>\n<li>not so easy to start with</li>\n<li>not from MS</li>\n<li>there are many tools, but you have to search for</li>\n</ul>\n\n<p>Between the 2 ORMs</p>\n\n<p>i would choose LinqToSql if:</p>\n\n<ul>\n<li>db-schema == classes</li>\n<li>only ever use MS SQL Server</li>\n<li>shop only allows MS-Products</li>\n</ul>\n\n<p>i would choose Nhibernate if:</p>\n\n<ul>\n<li>richer objectmodel</li>\n<li>legacy db-schema</li>\n<li>DB other than MS SQL Server or support multiple</li>\n<li>performance critical (i think NH has more features to optimise performance than LinqToSql)</li>\n</ul>\n\n<p>NOTE: this is my personal view. I deal mostly with (crazy) legacy dbs and complex ETL jobs where the object model helps a lot over SQL.</p>\n'}, {'answer_id': 8407766, 'author': 'CedX', 'author_id': 1084485, 'author_profile': 'https://Stackoverflow.com/users/1084485', 'pm_score': 0, 'selected': False, 'text': '<p>I don\'t use (or even know) NHibernate, I just want to give my testimony: I use LINQ to SQL since about 2 years with MySQL and PostgreSQL databases (using <a href="http://code.google.com/p/dblinq2007/" rel="nofollow">DbLinq</a> on Windows, using <a href="http://www.mono-project.com/" rel="nofollow">Mono</a> on Linux and Mac OS X).</p>\n\n<p>So LINQ to SQL is NOT limited to Microsoft products.</p>\n\n<p>I can confirm that LINQ to SQL is very well suited for small and medium projects, or large projects where you have the absolute control of the database structure.\nAs the reviews indicate, LINQ to SQL has some limitations that make it an inappropriate tool when there is no direct mapping between the database tables and the entity classes.</p>\n\n<p>Note : LINQ to SQL doesn\'t support many-to-many relationships (but this can be easily achieved with a few code lines).</p>\n'}, {'answer_id': 11229157, 'author': 'Oualid KTATA', 'author_id': 1486031, 'author_profile': 'https://Stackoverflow.com/users/1486031', 'pm_score': 0, 'selected': False, 'text': '<p>The main drawback of NHibernate is the inability to make use of <strong>method calls</strong>. They cannot be translated to SQL. To circumvent that, you have to recreate expression trees which is difficult to do.</p>\n'}]
['https://Stackoverflow.com/questions/53417', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2847/']