本文介绍了使用 WebApi ( $inlinecount ) 进行 OData 分页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 OData 对从 web api 调用返回的一长串项目进行分页.我可以通过带有开始和结束索引的 url 过滤数据.

I am using OData to paginate a long list of items returned from a web api call. I can filter the data via the url with the start and end index.

我的问题是,我怎么知道物品的总数?因此,我可以在调用 Web api 的移动设备上显示第 1 页,共 3 页(20 项).

The question I have is, how do I know the total number of items? So I can display Page 1 of 3 (20 items) on my mobile device which calls the web api.

推荐答案

可以在查询中使用 $inlinecount=allpages 来获取结果中所有实体的数量,不带top并跳过.例如:

You can use $inlinecount=allpages in the query to get the count of all the entities in the results without the top and skip. For example:

http:///services.odata.org/OData/OData.svc/Products?$top=1&skip=1&$inlinecount=allpages

返回单个产品,但内联计数为 9(因为实体集中有 9 个产品).

Returns a single product but also inline count of 9 (since there are 9 products in the entity set).

这篇关于使用 WebApi ( $inlinecount ) 进行 OData 分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 20:09