<p><strong>When using the Entity Framework, does ESQL perform better than Linq to Entities?</strong> </p>

<p>I'd prefer to use Linq to Entities (mainly because of the strong-type checking), but some of my other team members are citing performance as a reason to use ESQL. I would like to get a full idea of the pro's/con's of using either method.</p>

[{'answer_id': 38689, 'author': 'lomaxx', 'author_id': 493, 'author_profile': 'https://Stackoverflow.com/users/493', 'pm_score': 1, 'selected': False, 'text': '<p>The more code you can cover with compile time checking for me is something that I\'d place a higher premium on than performance. Having said that at this stage I\'d probably lean towards ESQL not just because of the performance, but it\'s also (at present) a lot more flexible in what it can do. There\'s nothing worse than using a technology stack that doesn\'t have a feature you really really need.</p>\n\n<p>The entity framework doesn\'t support things like custom properties, custom queries (for when you need to really tune performance) and does not function the same as linq-to-sql (i.e. there are features that simply don\'t work in the entity framework).</p>\n\n<p>My personal impression of the Entity Framework is that there is a lot of potential, but it\'s probably a bit to "rigid" in it\'s implementation to use in a production environment in its current state.</p>\n'}, {'answer_id': 40743, 'author': 'Chris Gillum', 'author_id': 2069, 'author_profile': 'https://Stackoverflow.com/users/2069', 'pm_score': 2, 'selected': False, 'text': '<p>Entity-SQL (eSQL) allows you to do things such as dynamic queries more easily than LINQ to Entities.  However, if you don\'t have a scenario that requires eSQL, I would be hesitant to rely on it over LINQ because it will be much harder to maintain (e.g. no more compile-time checking, etc).</p>\n\n<p>I believe LINQ allows you to precompile your queries as well, which might give you better performance.  Rico Mariani <a href="http://blogs.msdn.com/ricom/archive/2007/07/05/dlinq-linq-to-sql-performance-part-4.aspx" rel="nofollow noreferrer">blogged about LINQ performance</a> a while back and discusses compiled queries.</p>\n'}, {'answer_id': 306060, 'author': 'ADB', 'author_id': 3610, 'author_profile': 'https://Stackoverflow.com/users/3610', 'pm_score': 2, 'selected': False, 'text': "<p>ESQL can also generate some particularly vicious sql. I had to track a problem with such a query that was using inherited classes and I found out that my pidly-little ESQL of 4 lines got translated in a 100000 characters monster SQL statetement. </p>\n\n<p>Did the same thing with Linq and the compiled code was much more managable, let's say 20 lines of SQL.</p>\n\n<p>Plus, what other people mentioned, Linq is strongly type, although very annoying to debug without the edit and continue feature.</p>\n\n<p>AD</p>\n"}, {'answer_id': 356511, 'author': 'Royd Brayshay', 'author_id': 35043, 'author_profile': 'https://Stackoverflow.com/users/35043', 'pm_score': 5, 'selected': True, 'text': '<p>The most obvious differences are:</p>\n\n<p>Linq to Entities is strongly typed code including nice query comprehension syntax. The fact that the “from” comes before the “select” allows IntelliSense to help you.</p>\n\n<p>Entity SQL uses traditional string based queries with a more familiar SQL like syntax where the SELECT statement comes before the FROM. Because eSQL is string based, dynamic queries may be composed in a traditional way at run time using string manipulation.</p>\n\n<p>The less obvious key difference is:</p>\n\n<p>Linq to Entities allows you to change the shape or "project" the results of your query into any shape you require with the “select new{... }” syntax. Anonymous types, new to C# 3.0, has allowed this.</p>\n\n<p>Projection is not possible using Entity SQL as you must always return an ObjectQuery&lt;T&gt;. In some scenarios it is possible use ObjectQuery&lt;object&gt; however you must work around the fact that .Select always returns  ObjectQuery&lt;DbDataRecord&gt;. See code below...</p>\n\n<pre><code>ObjectQuery&lt;DbDataRecord&gt; query = DynamicQuery(context,\n        "Products",\n        "it.ProductName = \'Chai\'",\n        "it.ProductName, it.QuantityPerUnit");\n\npublic static ObjectQuery&lt;DbDataRecord&gt; DynamicQuery(MyContext context, string root, string selection, string projection)\n{\n    ObjectQuery&lt;object&gt; rootQuery = context.CreateQuery&lt;object&gt;(root);\n    ObjectQuery&lt;object&gt; filteredQuery = rootQuery.Where(selection);\n    ObjectQuery&lt;DbDataRecord&gt; result = filteredQuery.Select(projection);\n    return result;\n}\n</code></pre>\n\n<p>There are other more subtle differences described by one of the team members in detail <a href="http://blogs.msdn.com/diego/archive/2007/12/20/some-differences-between-esql-and-linq-to-entities-capabilities.aspx" rel="noreferrer">here</a> and <a href="http://blogs.msdn.com/diego/archive/2007/11/11/choosing-an-entity-framework-api.aspx" rel="noreferrer">here</a>.</p>\n'}, {'answer_id': 864281, 'author': 'chrishawn', 'author_id': 28681, 'author_profile': 'https://Stackoverflow.com/users/28681', 'pm_score': 2, 'selected': False, 'text': '<p>nice graph showing performance comparisons here:\n    <a href="http://toomanylayers.blogspot.com/2009/01/entity-framework-and-linq-to-sql.html" rel="nofollow noreferrer">Entity Framework Performance Explored</a>\nnot much difference seen between ESQL and Entities\nbut overall differences significant in using Entities over direct Queries</p>\n\n<p>Entity Framework uses two layers of object mapping (compared to a single layer in LINQ to SQL), and the additional mapping has performance costs. At least in EF version 1, application designers should choose Entity Framework only if the modeling and ORM mapping capabilities can justify that cost.</p>\n'}, {'answer_id': 922435, 'author': 'Jeff', 'author_id': 13338, 'author_profile': 'https://Stackoverflow.com/users/13338', 'pm_score': 0, 'selected': False, 'text': "<p>For direct queries I'm using linq to entities, for dynamic queries I'm using ESQL.  Maybe the answer isn't either/or, but and/also.</p>\n"}]
['https://Stackoverflow.com/questions/38647', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/708/']