【问题标题】:How to sort IQueryable<string> using odata?如何使用 odata 对 IQueryable<string> 进行排序?
【发布时间】:2014-06-16 18:58:51
【问题描述】:

我有一个返回 IQueryable 的 web api 我想按 asc 顺序对字符串列表进行排序

我的 MyAPIController 代码

[Queryable]
    public IQueryable<string> Get()
    {

     //result
        return result.AsQueryable();
    }

我尝试使用

http://www.ServerAddress.com/api/MyAPI?$orderby

但它给出了 HTTP/1.1 400 Bad Request 错误。 什么是正确的排序语法?

【问题讨论】:

    标签: asp.net-mvc c#-4.0 odata asp.net-web-api


    【解决方案1】:

    排序 URL 应该是: http://www.ServerAddress.com/api/EntitySetName?$orderby=PropertyName asc

    【讨论】:

      【解决方案2】:

      OData 3 语法为:

      ?$orderby=$it asc
      

      【讨论】:

        猜你喜欢
        • 2011-04-07
        • 2012-09-20
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-08-28
        • 2017-11-02
        • 2018-11-25
        相关资源
        最近更新 更多