get count from oData enabled web api Get function

460 views Asked by At

i have an oData enabled classic REST web api controller with a Get function like

[EnableQuery()]
    public IQueryable<StoreCommand> Get()
    {
        return _storeCommandService.GetAllStoreCommands().AsQueryable();
    }

i need to understand how i can make a call to get only the count of records using some url

i tried

http://localhost:9910/api/storeCommandsrest?$count

but i get

Message: "The query parameter '$count' is not supported."

please note that i am using MongoDb that is returning IQueryable of collection.

1

There are 1 answers

1
Yi Ding - MSFT On

If you want to get only the count, try

http://localhost:9910/api/storeCommandsrest/$count