'OData Count and ODATA context fields not in response
I would like to use ODATA. Unfortunately I get neither count nor odata.context back. Select, filter, orderBy are working though. Does anyone have an idea where my error is?
[AllowAnonymous]
[ApiController]
[Route("api/v1/wea")]
[Produces("application/json")]
[ODataRouteComponent("api/v1/wea")]
public class WeatherForecastODataController : ODataController
{
[HttpGet]
[EnableQuery]
public IEnumerable<WeatherForecast> Get()
{
_logger.LogWarning("Get Forecast");
return _forecasts;
}
}
public static IMvcBuilder AddODataOptions(this IMvcBuilder builder)
{
builder.AddOData(options => {
var defaultBatchHandler = new DefaultODataBatchHandler();
defaultBatchHandler.MessageQuotas.MaxNestingDepth = 2;
defaultBatchHandler.MessageQuotas.MaxOperationsPerChangeset = 10;
defaultBatchHandler.MessageQuotas.MaxReceivedMessageSize = 100;
var model1 = EdmBuilder.BuildV1();
options.Select().Filter().OrderBy().Count().SetMaxTop(2).Expand();
options.AddRouteComponents("api/v1", model1, defaultBatchHandler);
});
return builder;
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
