Skip to content

$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=true

Response:

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:

  1. The engine calls resolver->count($plan) (a separate query)
  2. The count is included as @odata.count in the JSON response header
  3. The regular resolver->resolve($plan) streams the paginated entities

The count query applies $filter and $search but not $top, $skip, or $orderby.

OData: MIT | Core: BSL 1.1 | SDK: Commercial License