Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Orderby doesn't work with more than 1 column #84

Open
jods4 opened this issue Jul 19, 2019 · 0 comments
Open

Orderby doesn't work with more than 1 column #84

jods4 opened this issue Jul 19, 2019 · 0 comments

Comments

@jods4
Copy link

jods4 commented Jul 19, 2019

I have a bug with multi-column sort in my project and looking at the code it seems that the order of multiple fields is not respected.

If you look here at the loop that applies sort:

foreach (var column in columns)

You will notice that the ordering of columns is in fact the order of declared properties on the type:

IEnumerable<PropertyInfo> properties = typeof(T).GetProperties();

Moreover, even if you fixed this by iterating orderClause, it would still be incorrect because it's a Dictionary<string, bool>. When the query string is parsed, each column in orderby is put into a Dictionary but Dictionary doesn't guarantee iteration order. So as soon as it's parsed, the ordering of orderby fields is lost.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant