I basically have a lot of poorly designed code to do something that, I'm sure, can be done far more elegantly.
What I'm trying to do is grab the last 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's a foreach loop that is designed to run only once. Crappy code! What's a "best practice" way to accomplish the same thing?