In this specific case, you can just use
count
as argument for
Take
:
var testdata = (from s in spe.contacts select s).OrderByDesending(x=>x.id).Take(count);
In other cases, if you do not return an anonymous type, you can use
IQueryable<Type>
, where
Type
is the type of the elements you return.
IQueryable<Type> testdata = null;
if (testdata != null)
{
}
else
{
}