I'm creating a .Net Core 3.1 Web Api Project where i have the following codes.
class Person{
string name;
int age;
}
class Student: Person{
string grade;
}
class Teacher: Person{
List<string> courses;
}
[HttpPost]
savePersonList([FromBody] List<Person> personList){
// Do something with the personList;
}
I call the api savePersonList and pass a list of students and teachers to it. However in the backend the personlist only give me Person object, the properties of Teacher and Student are not there.
What do i have to do to get the full properties of the list. The solution to this problem should be generalized because i have other controllers which got other type of objects.
Thanks.