Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem while translating the OData groupBy request to EF Core request #2019

Open
rleos opened this issue Jan 10, 2020 · 5 comments
Open

Problem while translating the OData groupBy request to EF Core request #2019

rleos opened this issue Jan 10, 2020 · 5 comments

Comments

@rleos
Copy link

rleos commented Jan 10, 2020

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_0[TFilter,TFilterAsync](ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResultExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext[TFilter,TFilterAsync](State& next, Scope& scope, Object& state, Boolean& isCompleted)
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)

@xuzhg
Copy link
Member

xuzhg commented Jan 14, 2020

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

@xuzhg xuzhg transferred this issue from OData/odata.net Jan 14, 2020
@kosinsky
Copy link
Contributor

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

@rleos
Copy link
Author

rleos commented Jan 31, 2020

Any news about this ?

@Bilal-El-Mursi
Copy link

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

@cilerler
Copy link

duplicate #2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants