I basically have a lot of poorly designed code to do something that, I am sure, can be made much more elegant.
What I'm trying to do is grab the latest date from a database table.
var Result =
from a in DB.Table
orderby a.Date descending
select new {Date = a};
foreach(var Row in Result)
{
LastDate = Row.Date.Date;
break;
}
Basically, there is a foreach loop that is designed to run only once. Shitty code! What is the best practice way to do the same thing?
source
share