I'm trying to replicate SQL's ORDER BY
.
I'm fetching data from several tables and adding it to a dictionary. Everything is working fine, but I would like to be able to order the data dynamically. Meaning the user might want to order it by username, date, etc.
string SortBy = Request.QueryString["SortBy"];
string SortOrder = Request.QueryString["SortOrder"];
foreach (KeyValuePair<Main_key, Main_data> entry in mainTable.OrderBy(key=> key.Value.username)
{
...
}
I want to make this part dynamic:
key.Value.username
Depending on the user input.
I'm aware of this answer and mainly of this snippet that I'm trying to make it work, but because i'm using a structure in the KeyValuePair, it's not working.