Reputation: 239
I have the following OData function configuration:
ODataConventionModelBuilder builder = new ODataConventionModelBuilder();
var function = builder
.Function("GetValues")
.ReturnsCollection<ObjectType>();
function.Parameter<int>("parm1");
With the following controller action:
[ODataRoute("GetValues(parm1={parm1})")]
[RequireOperation(ClientPermissionsEnum.HSA)]
[EnableQuery(AllowedQueryOptions = ODataConfig.AllowedOptions)]
public IQueryable<ObjectType> GetValues(int parm1)
{
return _repository.GetValues(parm1).AsQueryable());
}
The ODataConfig.AllowedOptions includes: skip, orderby, count, top, format and filter.
When I go to the http://..../GetValues(1)?%24format=json&%24top=5&%24count=true url, I get "@odata.context" and "value" properties of the response. The "value" property correctly includes only the first 5 results. I can issue another request with the proper skip values and get the next 5 and so on. However, the responses never include an "@odata.count" property. This prevents the client from being aware that there are more results than can fit on a single page.
Is it possible to configure an unbound function to include the count in the response for client side paging? This works fine for entity bound odata routes, but I would prefer to not have to do that as the parm1 value is not currently a property of the ObjectType class.
Upvotes: 0
Views: 458
Reputation: 2132
what version are you using, this is fixed in https://github.com/OData/WebApi/issues/484, I think you can upgrade your OData Web API to 5.9.1 or breaking change release 6.0.0 and try again. https://www.nuget.org/packages/Microsoft.AspNet.OData
Upvotes: 0