Ok so in our project I'm using System.Linq.Dynamic library but I just noticed that I cannot do the following:
myDataSource.OrderByDescending("someColumnName")
Because I get the following error:
Overload resolution failed because no accessible OrderByDescending
can be called with these arguments...
It seems that the Library only support OrderBy("someColumnName")
. Is there a reason for this and how would I bypass this issue if I want to reorder the records in descending order? Do I have to user Reverse()
for example OrderBy("someColumnName").Reverse()
? Seems like a hack...
Any advice would be greatly appreciated...
Assuming that you are using the DynamicQuery Helper files from the Microsoft sample library (Which are in the namespace System.Linq.Dynamic) then after reading the source code it looks like you need to specify the ordering you want as follows:
myDataSource.OrderBy("someColumnName descending")
If you're using string values (like me) you'll have to concatenate it to the string like this:
myDataSource.OrderBy(columnName + " descending");
Don't forget to add a space before 'descending' otherwise you'll get an error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With