title: Select records with max property value per group
body: <p>I've got a data set like this:</p>
  
  <pre><code>GroupName   GroupValue   MemberName   MemberValue
  'Group1'    1            'Member1'    1
  'Group1'    1            'Member2'    2
  'Group2'    2            'Member3'    3
  'Group2'    2            'Member4'    2
  'Group3'    2            'Member5'    4
  'Group3'    2            'Member6'    1
  </code></pre>
  
  <p>What I want to select is the rows that have the maximum <code>MemberValue</code> per <code>GroupName</code>, but only for those <code>GroupName</code>s that have the largest <code>GroupValue</code>, and pass them into a delegate function. Like this:</p>
  
  <pre><code>'Group2'    2            'Member3'    3
  'Group3'    2            'Member5'    4
  </code></pre>
  
  <p>So far I've tried this format...</p>
  
  <pre><code>data.Where(maxGroupValue =&gt; 
      maxGroupValue.GroupValue == data.Max(groupValue =&gt; groupValue.GroupValue))
  .Select(FunctionThatTakesData)
  </code></pre>
  
  <p>...but that just gives me every member of Group2 and Group3. I've tried putting a <code>GroupBy()</code> before the <code>Select()</code>, but that turns the output into an <code>IGrouping&lt;string, DataType&gt;</code> so <code>FunctionThatTakesData()</code> doesn't know what to do with it, and I can't do another <code>Where()</code> to filter out only the maximum <code>MemberValue</code>s.</p>
  
  <p>What can I do to get this data set properly filtered and passed into my function?</p>