System.Linq.Dynamic不支持OrderByDescending("someColumn")? [英] System.Linq.Dynamic does not support OrderByDescending("someColumn")?

查看:254
本文介绍了System.Linq.Dynamic不支持OrderByDescending("someColumn")?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,所以在我们的项目中,我使用的是System.Linq.Dynamic库,但是我只是注意到我无法执行以下操作:

Ok so in our project I'm using System.Linq.Dynamic library but I just noticed that I cannot do the folowing:

myDataSource.OrderByDescending("someColumnName")

myDataSource.OrderByDescending("someColumnName")

因为出现以下错误:

重载解析失败,因为无法使用这些参数调用可访问的OrderByDescending ...

Overload resolution failed because no accessable OrderByDescending can be called with these arguments...

似乎库仅支持OrderBy("someColumnName").有这个原因吗?如果我想按降序对记录重新排序,该如何避免这个问题?我是否必须使用Reverse()例如OrderBy("someColumnName").Reverse()?好像是黑客...

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...

推荐答案

假定您使用的是Microsoft示例库中的DynamicQuery Helper文件(位于名称空间System.Linq.Dynamic中),然后在阅读源代码后使用它看起来您需要按如下方式指定所需的顺序:

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")

这篇关于System.Linq.Dynamic不支持OrderByDescending("someColumn")?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆