I have existing code that works very well and it finds the maximum value of a data column in the data table. Now I would like to refine this and find the maximum value per empid.
What change would be needed? I do not want to use LINQ.
I am right now using this: memberSelectedTiers.Select(“Insert_Date = MAX(Insert_Date)”)
and I need to group it by Empid.
My code is as below.
DataTable memberApprovedTiers = GetSupplierAssignedTiersAsTable(this.Customer_ID, this.Contract_ID);
//get row with maximum Insert_Date in memberSelectedTiers
DataRow msRow = null;
if (memberSelectedTiers != null && memberSelectedTiers.Rows != null && memberSelectedTiers.Rows.Count > 0)
{
DataRow[] msRows = memberSelectedTiers.Select("Insert_Date = MAX(Insert_Date)");
if (msRows != null && msRows.Length > 0)
{
msRow = msRows[0];
}
}
You can use LINQ to achieve this. I think the following will work (don’t have VS to test):