Open mansurdegirmenci opened 4 months ago
Digging through the sources I found that GetQuery() / GetQueryAsync() sets the OData feature "TotalCount" if you request $count. So this is my solution/workaround I came up with to get $count working:
public IActionResult Get([FromServices] ODataQueryOptions<Entity> options) {
IQueryable<Entity> query = dbContext.Entities.GetQuery(mapper, options);
return options.Count?.Value == true ? Ok(options.Request.ODataFeature().TotalCount) : Ok(query);
}
url: https://localhost:5001/api/Photos/$count
When I make a request to the specified url, it gives the following error, other requests work fine. The version I use is the latest version.
Microsoft.OData.ODataException: The value of type 'Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable`1[[WebUI.DataTransferObject.Server.PhotoDto, WebUI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' could not be converted to a raw string.