At first,I do not use dynamic
,I just use the code like this,and it works well.
List<Student> result2 = StudentRepository.GetStudent(sex,age).ToList();
IQueryable rows2 = result2.AsQueryable();
But when I change it to dynamic
,it is wrong.
dynamic result = GetPeopleData(sex,age);
IQueryable rows = result.AsQueryable();
and I add a method like this,I build the project it show that List do not have the AsQueryable method.How to change it?
private dynamic GetPeopleData(int sex, int age)
{
if(sex>30)
return StudentRepository.GetStudent(sex,age).ToList();
else
return TeacherRepository.GetTeacher(sex, age).ToList();
}