How to get only Odata.Count without value

前端 未结 2 1829
梦毁少年i
梦毁少年i 2021-02-19 03:13

Is there any way I can get only count of the data in response payload without any value array?

I am using ODataV4.0 with Webapi 2.2. Currently it returns all the value

2条回答
  •  再見小時候
    2021-02-19 03:25

    Set the $top to zero and $count to true.

    For example: http://services.odata.org/V4/Northwind/Northwind.svc/Customers?$count=true&$top=0

    returns the count but no results

    {"@odata.context":"http://services.odata.org/V4/Northwind/Northwind.svc/$metadata#Customers","@odata.count":91,"value":[]}

    Count is calculated after applying the $filter, but without factoring in $top and $skip.

    For example: http://services.odata.org/V4/Northwind/Northwind.svc/Customers?$count=true&$top=0&$filter=Country%20eq%20%27Germany%27

    informs you that there are 11 results where the Country is 'Germany', but without returning any records in the response.

提交回复
热议问题