$count
The $count option adds the total number of matching entities to the response.
As a query option
GET /odata/Products?$count=true
GET /odata/Products?$top=10&$count=trueResponse:
json
{
"@odata.context": "...",
"@odata.count": 42,
"value": [ ... ]
}The count reflects the total matching entities after $filter and $search are applied, but ignoring $top and $skip. This lets clients display "showing 1-10 of 42" while paginating.
How it works
When $count=true is present:
- The engine calls
resolver->count($plan)(a separate query) - The count is included as
@odata.countin the JSON response header - The regular
resolver->resolve($plan)streams the paginated entities
The count query applies $filter and $search but not $top, $skip, or $orderby.