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.
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:
AutoQueryable/src/AutoQueryable/Helpers/QueryBuilder.cs
Line 273 in 1383b3d
You will notice that the ordering of
columnsis in fact the order of declared properties on the type:AutoQueryable/src/AutoQueryable/Helpers/QueryBuilder.cs
Line 256 in 1383b3d
Moreover, even if you fixed this by iterating
orderClause, it would still be incorrect because it's aDictionary<string, bool>. When the query string is parsed, each column inorderbyis put into aDictionarybutDictionarydoesn't guarantee iteration order. So as soon as it's parsed, the ordering oforderbyfields is lost.