Skip to content

How to add a $count endpoint with attribute routing? #1097

Answered by mikepizzo
sliekens asked this question in Q&A
Discussion options

You must be logged in to vote

As @xuzhg says, OData expects the path for /$count to return the collection of documents, so it can apply query options (i.e. $filter). So, you should be able to annotate a single GetDocuments controller method that returns all documents with both [HttpGet("odata/Documents")] and [HttpGet("odata/Documents/$count")]

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@sliekens
Comment options

Comment options

You must be logged in to vote
1 reply
@sliekens
Comment options

Answer selected by sliekens
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants