public class MyData
{
public int Value1 { get; set; }
public int Value2 { get; set; }
public int Value3 { get; set; }
}
public class MyViewData
{
List<MyData> MyDatas = new List<MyData>();
public int GetMaxValue(Expression<Func<MyData, int>> 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 => d.Value1);
}
}
How do I implement GetMaxValue? I want to give it a property name through a lambda and have GetMaxValue perform a LINQ Max query.
Thanks!