For the backend of a website, I need to fetch certain datacolumns from a database, depending on which sitesettings the user has. So there is no way of knowing which columns I will need beforehand.
Is there any way I can make a list of "objects" containing only the different types I need to return to the frontend?
For example:
The class students is stored in the database:
Students
{
string name;
int age;
double averageGrade;
string class;
Student bestFriend;
}
Let's say the user on the site wants to see only the student's name and best friend, how can I put those in an object, and put those objects in a list?
exampleStudent {name, bestFriend};
Thanks in advance!
One solution would be to store the properties using a dictionary:
Dictionary<string, object> student = new Dictionary<string, object>();
student["name"] = "Alex";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.