My question is similar to: web-api-odata-inlinecount-not-working
I have installed the following packages:
<packages>
<package id="Microsoft.AspNet.Cors" version="5.0.0-rc1" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Client" version="5.0.0-rc1" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.0.0-rc1" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Cors" version="5.0.0-rc1" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.OData" version="5.0.0-rc1" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.SelfHost" version="5.0.0-rc1" targetFramework="net45" />
<package id="Microsoft.Data.Edm" version="5.6.0" targetFramework="net45" />
<package id="Microsoft.Data.OData" version="5.6.0" targetFramework="net45" />
<package id="Newtonsoft.Json" version="5.0.6" targetFramework="net45" />
<package id="System.Spatial" version="5.6.0" targetFramework="net45" />
</packages>
The api is selfhosted with cors and attribute routing enabled.
// used for development purpose only
var cors = new EnableCorsAttribute("*", "*", "*");
config.EnableCors(cors);
// enables attribute routing
config.MapHttpAttributeRoutes();
The method GetAllProducts of the ProductController:
[Queryable]
[HttpGet("products")]
public PageResult<ProductViewModel> GetAllProducts(ODataQueryOptions<ProductViewModel> options)
{
//return products.AsQueryable();
ODataQuerySettings settings = new ODataQuerySettings()
{
PageSize = 2
};
IQueryable results = options.ApplyTo(products.AsQueryable(), settings);
Uri uri = Request.GetNextPageLink();
long? inlineCount = Request.GetInlineCount();
PageResult<ProductViewModel> response = new PageResult<ProductViewModel>(
results as IEnumerable<ProductViewModel>,
uri,
inlineCount);
return response;
}
The output by querying
http://localhost/api/products
is as follows:
If I'm appending ?$inlinecount=allpages the output by querying
http://localhost/api/products?$inlinecount=allpages
is as follows:
During debugging the uri and count are properly set but not mapped in the json response:
What I'm missing?