Get Requests Error :
Object of type ‘System.Linq.EnumerableQuery1[Microsoft.AspNetCore.OData.Query.Wrapper.SelectAllAndExpand
1[Core.Objects.Result1[Core.Entities.Invoice]]]' cannot be converted to type 'System.Linq.IQueryable
1[Core.Objects.Result`1[Core.Entities.Invoice]]’
Solution :
I found reason that this error occurred and I corrected it
In Odata if you register enablequery globbaly such this
Services .AddMvc() .AddControllers() .AddOData(options => options .AddRouteComponents(“odata”, OdataBuilder.GetEdmModel()) .EnableQueryFeatures(null) ).AddODataNewtonsoftJson();
you must dont use EnableQuery attribute before method
Before
type here
[EnableQuery]
[HttpGet]
public IActionResult Get()
{
var Items = _unitOfWork.Set<TEntity>();
return Ok(Items);
}
After :
[HttpGet]
public IActionResult Get()
{
var Items = _unitOfWork.Set<TEntity>();
return Ok(Items);
}
Removing the [EnableQuery] Fixed the problems