title: Find the max value in a grouped list using Linq
body: <p>I have a linq expression that returns transactions in groups. Each transaction has a numerical value and I now need to know what is the highest value from all the transactions returned. This value is held in a field called TransactionId</p>
  
  <p>Here is the expression I am using to get the grouped list.</p>
  
  <pre><code>            var transactions = ctx.MyTransactions
                                 .Where (x =&gt; x.AdapterId == Id)
                                 .GroupBy(x =&gt; x.DeviceTypeId);
  </code></pre>
  
  <p>I now need to write an expression that works on the “transactions” grouped list to find the “max” of the TransactionId field. I’ve tried different ideas but none seem to work with the grouped results. I’m new to linq so I’m not sure how to do this.</p>