OData / ODataSamples

Samples: For ODataLib, OData Web API, RESTier, etc.
http://odata.github.io/
Other
296 stars 223 forks source link

How can I return the total count with the EdmEntityObjectCollection for paging? #127

Open rogerskk opened 4 years ago

rogerskk commented 4 years ago

I'm using the DynamicEdmModelCreation sample and I've generated my EdmModel from a database query because what I'm working on has to support multiple client databases and some have custom fields so not every table will be the same.

I want to be able to do paging and have manually added the top and skip to my query getting the query options as follows: var model = EdmModelHelper.EdmModel; IEdmEntityType entityType = model.SchemaElements.OfType().First(c => c.Name == "Products");

        ODataQueryContext queryContext = new ODataQueryContext(model, entityType, path);
        ODataQueryOptions queryOptions = new ODataQueryOptions(queryContext, Request);

queryOptions.Count is read only. I'm not seeing how I can return the total count, even if I add $count=true in the url.