【问题标题】:odata.nextLink is not part of the responseodata.nextLink 不是响应的一部分
【发布时间】:2019-09-17 18:05:04
【问题描述】:

我正在关注this tuorial 在 asp.net web api 2 中使用 odata v3 设置实现分页

生成的odata控制器方法

public class Level2TableController : ODataController
    {
        private ProvisioningDMEntities db = new ProvisioningDMEntities();

        // GET: odata/Level2Table
        [EnableQuery(PageSize=10)]
        public IQueryable<Level2tableAllBudgets> GetLevel2Table()
        {
            return db.Level2tableAllBudgets.AsQueryable();
        }
}

当我调用 api/Level2Table?$top=5&$inlinecount=allpages 之类的链接时 我收到一个不包含 nextPage 链接的 odata 响应

我尝试了所有选项,例如将接受标头设置为 odata=verbose,但它仍然没有返回。

如何将 nextPage 链接包含在响应中?

【问题讨论】:

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


    【解决方案1】:

    如果您在请求中包含 $top=&lt;nr&gt;,OData 将不会提供 nextPage 链接。

    将您的请求修改如下:

    HTTP GET api/Level2Table?$inlinecount=allpages
    

    该服务将在您的情况下返回 10 个条目,因为那是您设置的 PageSize

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-02-16
      • 1970-01-01
      • 1970-01-01
      • 2016-01-06
      • 1970-01-01
      • 2014-07-15
      • 1970-01-01
      • 2018-05-16
      相关资源
      最近更新 更多