title: Why does LINQ-to-Entities put this query in a sub-select?
body: <p>I have the following LINQ query:</p>
  
  <pre><code>var queryGroups = (from p in db.cl_contact_event
                     select new Groups { inputFileName = p.input_file_name }).Distinct();
  </code></pre>
  
  <p>Which translates to the following when run:</p>
  
  <pre><code>SELECT 
  [Distinct1].[C1] AS [C1], 
  [Distinct1].[input_file_name] AS [input_file_name]
  FROM ( SELECT DISTINCT 
         [Extent1].[input_file_name] AS [input_file_name], 
         1 AS [C1]
         FROM [mel].[cl_contact_event] AS [Extent1]
  )  AS [Distinct1]
  </code></pre>
  
  <p>Now I'm pretty sure that the reason there is a sub-select is because I have the base LINQ query surrounded by () and then perform .Distinct() but I don't know enough about LINQ to be sure of this. If that's indeed the case is there a way to restructure/code my query so that a sub-select doesn't occur?</p>
  
  <p>I know that it probably seems that I'm just nit-picking here but I'm just curious.</p>