Getting this error for the orderby in where clause. I did this because previously, if I didn't define 'people' I'd get an error on the return for people saying the name 'people' doesnt exist in this current context. How do I fix this?
public JsonResult PersonsList(string birthyear)
{
TutorialDBContext db = new TutorialDBContext();
var NumericYear = Convert.ToInt32(birthyear);
IQueryable people;
if (birthyear == "All")
{
people = from m in db.persons
select m;
people = people.OrderByDescending(s => s.birthdate);
}
else
{
people = from m in db.persons
where m.birthdate.Year >= NumericYear
where m.birthdate.Year <= (NumericYear + 9)
select m;
}
return Json(people, JsonRequestBehavior.AllowGet);
}