使用skip和top进行OData分页 - 如何知道没有更多数据? [英] OData paging with skip and top - how to know that there is no more data?

查看:63
本文介绍了使用skip和top进行OData分页 - 如何知道没有更多数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 OData 源,它实现了 $skip$top 参数.返回了 x 个实体.比如说,我只有 250 个实体.然后我尝试像这样进行分页:

I have OData source, that implements $skip and $top parameters. There are x number of entities that are returned. Say, I have only 250 entities. And then I try to do the paging like this:

https://example.com/EntitySet?$top=30&$skip=220

如果我的跳过超过实体总数,我最终会从服务中超时.

If my skip goes beyond the number of total entities, I eventually get timeout from service.

是否有参数或数据通知我没有更多项目? 是否有可以/应该在 OData 端实现的东西,它会返回而不是超时?

Is there a parameter or data, that would inform me that there are no more items? Is there something that can/should be implemented on OData side, that gets returned instead of timeout?

推荐答案

对于 OData 2.0 和 OData 3.0 协议:你应该使用:$inlinecount=allpages

For OData 2.0 and OData 3.0 protocols: You should use: $inlinecount=allpages

http:///services.odata.org/OData/OData.svc/Products$inlinecount=allpages&$top=5&$format=json

标识前 5 个产品条目和包括产品条目总数的计数.

Identifies the first 5 Product Entries and includes a count of the total number of Product Entries.

对于 OData 4.0,您可以阅读响应中嵌入的 nextLink 注释.(参见示例此处)

For OData 4.0, you can read the nextLink annotation embeded in the response. (See example here)

4.5.5 Annotation odata.nextLink odata.nextLink 注释表明响应只是请求集合的一个子集实体或实体引用的集合.它包含一个 URL允许检索请求集合的下一个子集.

4.5.5 Annotation odata.nextLink The odata.nextLink annotation indicates that a response is only a subset of the requested collection of entities or collection of entity references. It contains a URL that allows retrieving the next subset of the requested collection.

这篇关于使用skip和top进行OData分页 - 如何知道没有更多数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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