I'm trying to make OData return the number of entities from the database when I pass it $inlinecount=allpages in the uri. I have read in Stack Overflow that I should return IQueryable instead of IHttpActionResult, however that didn't solve the problem. I also tried to follow the tutorials on the asp.net website, but that also didn't give any results.
[EnableQuery(
PageSize = BuildingConstants.BuildingsPerPage,
MaxTop = BuildingConstants.MaxBuildingsPerPage,
AllowedArithmeticOperators = AllowedArithmeticOperators.None,
AllowedLogicalOperators = AllowedLogicalOperators.None,
AllowedFunctions = AllowedFunctions.SubstringOf,
AllowedQueryOptions = AllowedQueryOptions.Filter | AllowedQueryOptions.OrderBy | AllowedQueryOptions.Top | AllowedQueryOptions.Skip | AllowedQueryOptions.InlineCount)]
[ResponseType(typeof(IEnumerable<ListedBuildingResponseModel>))]
public IQueryable<ListedBuildingResponseModel> Get()
{
var buildings = this.buildings
.GetBuildings()
.ProjectTo<ListedBuildingResponseModel>();
return buildings;
}
This is everything I have written regarding OData. The controller inherits ApiController, not ODataController. In the Register method I haven't added any OData routes or model builders. $top, $skip, $orderby and everything else is working just fine, but $inlinecount=allpages. Any suggestions on how to solve the problem?