c# - Grabbing Just The Top Entry From A LINQ Query -
I basically have a badly designed code to do something like this, I'm sure, it's more beautiful Can be done from
What I am trying to do is to catch the last date from the database table.
var Result = to a DB in Ordering a.Date descending object by new {date = a}; Foreign currency (diverse line in result) {end date = line.Det. date; break; }
Basically, there is a foreach loop which is designed to run only once. Dirty code! What is the "best practice" method to fulfill the same thing?
var first = result first ();
If the result set is empty, then it will throw an exception; You can use FirstOrDefault () which returns the tap if the result set is empty.
Comments
Post a Comment