JocaPC / sql-server-rest-api

Other
67 stars 16 forks source link

Is "$count" supported? #12

Open Rich-AU opened 4 years ago

Rich-AU commented 4 years ago

When I used "$count" in the request, I got this error: {"code":-1,"message":{"lang":"en","value":"Parameter $count is not supported.","innererror":null}}

But based on this document, it seems $count is supported: https://github.com/JocaPC/sql-server-rest-api/blob/master/doc/odata.md

Just want to clarify that if "$count" is supported? Thanks.

JocaPC commented 4 years ago

Actually it works. You just need to explicitly add a route that accepts $count: (see https://github.com/JocaPC/sql-server-rest-api/blob/master/TestApp/Controllers/RestApiController.cs#L88)

        [HttpGet("[controller]/odata/objects")]
        [HttpGet("[controller]/odata/objects/$count")]
        public async Task Objects()

Count is not one of the parameters it is specified using /$count.

You can also use $apply=aggregate(object_id with count as c) as alternative.