title: EntityFramework Any generates two EXISTS sql statements
body: <p>I want to use the LINQ 'Any' method with EntityFramework to check the existence of a record.</p>
  
  <p>Even with the most basic query:</p>
  
  <pre><code>DbContext.Users.Any()
  </code></pre>
  
  <p>The SQL statement generated by EF looks like this:</p>
  
  <pre><code>SELECT CASE 
  WHEN (EXISTS (SELECT 1 AS [C1] FROM [dbo].[User] AS [Extent1])) THEN cast(1 as bit) 
  WHEN (NOT EXISTS (SELECT 1 AS [C1] FROM [dbo].[User] AS [Extent2])) THEN cast(0 as bit) 
  END AS [C1]
  </code></pre>
  
  <p>Can I force EF to generate a single EXISTS statement, like this ?</p>
  
  <pre><code>SELECT
      (CASE
          WHEN EXISTS(
              SELECT NULL AS [EMPTY]
              FROM [User] AS [t0]
              ) THEN 1
          ELSE 0
       END) AS [value]
  </code></pre>
  
  <p>UPDATE</p>
  
  <p>In the following link, EF generates a single EXISTS statement: <a href="http://www.growingwiththeweb.com/2013/04/use-any-in-your-linq-to-sql-queries.html" rel="nofollow">http://www.growingwiththeweb.com/2013/04/use-any-in-your-linq-to-sql-queries.html</a>.</p>
  
  <p>I'm using EF 6.1.0 so looks like older versions did generate a single statement ?</p>