title: LINQ to SQL: Parameterized keySelector causes local evaluation in LINQPad
body: <p>I have a LINQ to SQL function that I'd allow to take the keySelector func as a paremeter:</p>
  
  <pre><code>Func&lt;App, string&gt; keySelector = a =&gt; a.Name;
  Apps.GroupBy(keySelector).Select(g =&gt; new { Key = g.Key, Count = g.Count() }).Dump();
  </code></pre>
  
  <p>However, when I look at the SQL that gets generated, it's clear that everything past the initial table query is getting evaluated locally, and to make matters worse it's querying every column of the table:</p>
  
  <pre><code>SELECT [t0].[AppId], [t0].[Name], [t0].[PublisherId], [t0].[PlatformId], [t0].[UnifiedAppId]
  FROM [apps].[App] AS [t0]
  </code></pre>
  
  <p>If I instead specify the keySelector function inline, it works as expected:</p>
  
  <pre><code>Apps.GroupBy(a =&gt; a.Name).Select(g =&gt; new { Key = g.Key, Count = g.Count() }).Dump();
  </code></pre>
  
  <hr>
  
  <pre><code>SELECT COUNT(*) AS [Count], [t0].[Name] AS [Key]
  FROM [apps].[App] AS [t0]
  GROUP BY [t0].[Name]
  </code></pre>
  
  <p>Any ideas how I can get this to work? Thanks!!</p>