Webapi: Problem while translating the OData groupBy request to EF Core request

Created on 10 Jan 2020  路  5Comments  路  Source: OData/WebApi

I'm upgrading OData and EF Core to 7.3.0 and 3.1. After doing so, i'm seeing new errors when trying to get a groupBy working. The same request did work before.

I wasn't sure if i should open an issue here or on EF Core github. If i'm wrong feel free to tell me and i'll move it.
The request that fails for me is : $apply=groupby((Actif))

Assemblies affected

Microsoft.AspNetCore.OData 7.3.0
Microsoft.EntityFrameworkCore 3.1.0

Reproduce steps

Get a project running with EF Core 3.1 and OData 7.3.0

Expected result

The result of the groupBy

Actual result

Exception is thrown :
An unhandled exception has occurred while executing the request.
System.InvalidCastException: Unable to cast object of type 'System.Boolean' to type 'Microsoft.AspNet.OData.Query.Expressions.GroupByWrapper'.
at get_NestedValue(Object )
at System.Text.Json.JsonPropertyInfoCommon4.GetValueAsObject(Object obj) at System.Text.Json.JsonSerializer.Write(Utf8JsonWriter writer, Int32 originalWriterDepth, Int32 flushThreshold, JsonSerializerOptions options, WriteStack& state) at System.Text.Json.JsonSerializer.WriteAsyncCore(Stream utf8Json, Object value, Type inputType, JsonSerializerOptions options, CancellationToken cancellationToken) at Microsoft.AspNetCore.Mvc.Formatters.SystemTextJsonOutputFormatter.WriteResponseBodyAsync(OutputFormatterWriteContext context, Encoding selectedEncoding) at Microsoft.AspNetCore.Mvc.Formatters.SystemTextJsonOutputFormatter.WriteResponseBodyAsync(OutputFormatterWriteContext context, Encoding selectedEncoding) at Microsoft.AspNetCore.Mvc.Infrastructure.ObjectResultExecutor.ExecuteAsyncEnumerable(ActionContext context, ObjectResult result, IAsyncEnumerable1 asyncEnumerable)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|29_0TFilter,TFilterAsync
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResultExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNextTFilter,TFilterAsync
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|27_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|24_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)

investigating

Most helpful comment

Any news about this ?

All 5 comments

@kosinsky Can you please take a look this issue and provide your suggestion?

EF Core and aggregations has some limitations. That one is fixable on OData side. However, we still need to do proper compatibility testing

Any news about this ?

Did you try to use services.AddControllers().AddNewtonsoftJson();? It seems to solve some of the issues.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

suadev picture suadev  路  3Comments

kpko picture kpko  路  3Comments

NetTecture picture NetTecture  路  4Comments

MDzyga picture MDzyga  路  5Comments

TehWardy picture TehWardy  路  5Comments