Hello,
see topic
How do I make a var return only firstordefault?
var GetLastCat = from c in db.table
foreach (CatTable cat in GetLastCat)
{
CatList.ID = cat.ID;
}
I don't know how to return only the first hit, since using ascending in my from would give me the latest entry this is what I want.

Jignesh TrivediRank #16 · 50.3K reputationPosted Jul 14, 2014, 9:13 PM EDT
hi,
TRY...
var GetLastCat = (from c in db.table orderby c.ID asc select c).FirstOrDefault();
if(GetLastCat != null)
{
CatList.ID = GetLastCat.ID;
}
hope this will help you.
D S5 reputationPosted Jul 14, 2014, 10:41 PM EDT