'Object of type System.Linq.EnumerableQuery cannot be converted to type System.Collections.Generic.IEnumerab
I'm running into a problem retrieving XML datatype with OData Query on the Web API, but in JSON format there is no problem at all.
Error saying this :
ArgumentException: Object of type 'System.Linq.EnumerableQuery
1[Microsoft.AspNetCore.OData.Query.Wrapper.SelectSome1[OData_WebAPI.WeatherForecast]]' cannot be converted to type 'System.Collections.Generic.IEnumerable`1[OData_WebAPI.WeatherForecast]'.
I'm just testing it on the sample Controller WeatherForecastController.cs file when you create a new Web API project.
[HttpGet("GetWeatherForecast/{format}"), FormatFilter]
[EnableQuery]
public IEnumerable<WeatherForecast> Get()
{
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = DateTime.Now.AddDays(index),
TemperatureC = Random.Shared.Next(-20, 55),
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
})
.ToArray();
}
Retrieving XML datatype without OData Query works fine, but I want it to work with OData Query, How to do that? hoping anyone could help me.
This works :
https://localhost:7110/WeatherForecast/GetWeatherForecast/xml
But not this
https://localhost:7110/WeatherForecast/GetWeatherForecast/xml?$select=Summary
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
