title: In Entity Framework, which is faster Any() or FirstOrDefault()?
body: <p>I'm a newbie in Entity Framework and SQL. I would like to know which one is (a little) faster: <code>Any()</code> or <code>FirstOrDefault()</code>. See below of how I want to use them.</p>
  
  <p><strong>Option 1</strong></p>
  
  <pre><code>if(Comments.Select(c=&gt;c.ObjectId).FirstOrDefault()&gt;0) {...}
  </code></pre>
  
  <p><em>Generated SQL</em></p>
  
  <pre><code>SELECT TOP (1) 
  [c].[ObjectId] AS [ObjectId]
  FROM [dbo].[Comments] AS [c]
  </code></pre>
  
  <p><strong>Option 2</strong></p>
  
  <pre><code>if(Comments.Select(c=&gt;c.ObjectId).Any()) {...}
  </code></pre>
  
  <p><em>Generated SQL</em></p>
  
  <pre><code>SELECT 
  CASE WHEN ( EXISTS (SELECT 
      1 AS [C1]
      FROM [dbo].[Comments] AS [Extent1]
  )) THEN cast(1 as bit) WHEN ( NOT EXISTS (SELECT 
      1 AS [C1]
      FROM [dbo].[Comments] AS [Extent2]
  )) THEN cast(0 as bit) END AS [C1]
  FROM  ( SELECT 1 AS X ) AS [SingleRowTable1]
  </code></pre>