Firstly, I do not use dynamic , I just use such code, and it works well.
List<Student> result2 = StudentRepository.GetStudent(sex,age).ToList(); IQueryable rows2 = result2.AsQueryable();
But when I change it to dynamic , this is wrong.
dynamic result = GetPeopleData(sex,age); IQueryable rows = result.AsQueryable();
and I add such a method, I am building a project that shows that List does not have an 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(); }
source share