I have a datatable
which has a few columns. I want to return the one which matches my id, with the highest value in the verlabel
column, in this case I want to return 1.1
How do I achieve this? Current code just returns the column name into my string variable, rather than the actual value.
Namespace.EnquiryEngine.DataLists ds2 = new Namespace.EnquiryEngine.DataLists("VERSION");
Namespace.Common.KeyValueCollection ds2params = new Namespace.Common.KeyValueCollection();
ds2params.Add("id", class.ID);
ds2.ChangeParameters(ds2params);
System.Data.DataTable dt = ds2.Run(false) as System.Data.DataTable;
String version = Convert.ToString(dt.Rows[0]["version"]);
New code:
var highestVersion = (from row in dt.AsEnumerable()
where row.Field<int>("id") == doc.ID
select row.Field<double>("verlabel")).Max();