title: How write a LINQ expression that will return the maximum value of a field?
body: <pre><code>public class MyData
  {
      public int Value1 { get; set; }
      public int Value2 { get; set; }
      public int Value3 { get; set; }
  }
  
  public class MyViewData
  {
      List&lt;MyData&gt; MyDatas = new List&lt;MyData&gt;();
  
      public int GetMaxValue(Expression&lt;Func&lt;MyData, int&gt;&gt; action) {
          // get highest value of specified field in MyDatas, return value
          // pseudo code of what i'm looking for would be:
          // return action.Max()
      }
  
      public void Test() {
          int num = GetMaxValue(d =&gt; d.Value1);
      }
  }
  </code></pre>
  
  <p>How do I implement GetMaxValue? I want to give it a property name through a lambda and have GetMaxValue perform a LINQ Max query.</p>
  
  <p>Thanks!</p>