I have a DataSet with 1-3 tables, each table have a column named m_date (string) I want to get max value from all of them using LINQ.
I know how to get each table Maximum value:
var maxDate=ds.Tables[index].AsEnumerable()
.Max(x=>DateTime.Parse(x["m_date"].ToString())).ToString();
but I don't know how to get Max value from all the tables information
Edit:
I now have something like this which works:
DateTime maxDate=DateTime.MinValue;
foreach (DataTable tbl in ds.Tables)
{
DateTime maxDateCur=ds.Tables[index].AsEnumerable()
.Max(x=>DateTime.Parse(x["m_date"].ToString()));
maxDate=new DateTime[] {maxDateCur,maxDate}.Max();
}
but I have a feeling it could be done better.