title: LINQ Group by and having where clause
body: <p>Below is the SQL Query I am trying to translate </p>
  
  <pre><code>SELECT dbo.Contracts.Supplier 
  FROM dbo.Contracts INNER JOIN dbo.Products ON dbo.Contracts.Product = dbo.Products.Product
  where dbo.Products.ProductGroup='Crude'
  GROUP BY dbo.Contracts.Supplier
  </code></pre>
  
  <p>Am I doing something wrong because I do not get same results with the following LINQ</p>
  
  <pre><code>     var result = from c in context.Contracts
                       join p in context.Products on c.Product equals p.Product1
                       where p.Product1.Equals("Crude")
                       group c by c.Supplier into g    
                       select new { supplier = g.Key  };
  </code></pre>
  
  <p>It is generating a weird statement </p>
  
  <pre><code>SELECT 
  1 AS [C1], 
  [Distinct1].[Supplier] AS [Supplier]
  FROM ( SELECT DISTINCT 
  [Extent1].[Supplier] AS [Supplier]
  FROM [dbo].[Contracts] AS [Extent1]
  WHERE N'Crude' = [Extent1].[Product]
  )  AS [Distinct1]
  </code></pre>
  
  <p>Using distinct would work but to get same results, LINQ should be generating a statement like so (it's like it is ignoring the join):</p>
  
  <pre><code>SELECT distinct dbo.Contracts.Supplier 
  FROM dbo.Contracts INNER JOIN dbo.Products ON dbo.Contracts.Product = dbo.Products.Product
  where dbo.Products.ProductGroup='Crude'
  </code></pre>