Skip to content

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

Description

@jods4

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions