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 TrivediPosted Jul 15, 2014, 1:13 AM
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 SPosted Jul 15, 2014, 2:41 AM