I have an EF model from which I select a sub-set of data to present in ASP.NET. When I am presenting this output I loop through the returned objects. I would like to know when I am presenting the object with the highest value (to format it differently).
ObjectTable
Category Item Value
X A 1.0
X B 14.0
X C 9.0
Y D 18.0
I can return the items I want to view with:
var obj = from o in ObjectTable where Category=="X" select o;
I want to know that B has the highest value.
I am very flexible with how this happens I just haven’t been able to come up with a sensible solution. Should I modify the LINQ statement to add a LET statement creating an obj.IsMax variable and if o.Value==o.Max make it TRUE and all other objects as FALSE, if so how? This route seems like it would be expensive?
Or could I extend the EF Model with a partial class and somehow calculate whether the model value is equal to the max value of the returned objects?
Or something completely different?
And looping thru anonymousObjList