c# - Return DataRow whose field is the max for specified column -
i want able datarow datarow array datarow has maximum value specified column in of datarows.
i imagine follow suit linq statement
dim minrow datarow = mydatarows.asenumerable.min(function(row) row.field(of decimal)("mycolumnname"))
however max function returns decimal instead of datarow. there easy syntax handles such query me?
and before asks, tag c# since in winforms can converted between each other using website.
if can use morelinq, can done using maxby()
:
var maxrow = mydatarows.maxby(r => r.field<decimal>("mycolumnname"));
but using regular linq:
var minrow = mydatarows.orderby(r => r.field<decimal>("mycolumnname")).firstordefault(); var maxrow = mydatarows.orderby(r => r.field<decimal>("mycolumnname")).lastordefault();
Comments
Post a Comment