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

Cosmos: bad exception for queries with aggregate selecting non-mapped type #20677

Open
maumar opened this issue Apr 18, 2020 · 1 comment
Open
Labels
area-cosmos area-query cosmos-query-refactor punted-for-6.0 punted-for-7.0 Originally planned for the EF Core 7.0 (EF7) release, but moved out due to resource constraints. type-bug
Milestone

Comments

@maumar
Copy link
Contributor

maumar commented Apr 18, 2020

query:

ctx.Orders.Average(o => o.ShipVia)

exception:

System.Collections.Generic.KeyNotFoundException : The given key 'EmptyProjectionMember' was not present in the dictionary.
  Stack Trace: 
    Dictionary`2.get_Item(TKey key)
    SelectExpression.GetMappedProjection(ProjectionMember projectionMember) line 131
    CosmosQueryableMethodTranslatingExpressionVisitor.TranslateAverage(ShapedQueryExpression source, LambdaExpression selector, Type resultType) line 193
    QueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression) line 119
    MethodCallExpression.Accept(ExpressionVisitor visitor)
    ExpressionVisitor.Visit(Expression node)
    QueryCompilationContext.CreateQueryExecutor[TResult](Expression query) line 91
    Database.CompileQuery[TResult](Expression query, Boolean async) line 71
    QueryCompiler.CompileQueryCore[TResult](IDatabase database, Expression query, IModel model, Boolean async) line 112
    <>c__DisplayClass9_0`1.<Execute>b__0() line 96
    CompiledQueryCache.GetOrAddQueryCore[TFunc](Object cacheKey, Func`1 compiler) line 76
    CompiledQueryCache.GetOrAddQuery[TResult](Object cacheKey, Func`1 compiler) line 51
    QueryCompiler.Execute[TResult](Expression query) line 92
    EntityQueryProvider.Execute[TResult](Expression expression) line 79
    Queryable.Average[TSource](IQueryable`1 source, Expression`1 selector)
    QueryAsserter`1.AssertAverage[TResult](Func`2 actualQuery, Func`2 expectedQuery, Expression`1 actualSelector, Expression`1 expectedSelector, Action`2 asserter, Boolean async) line 1305
    NorthwindAggregateOperatorsQueryTestBase`1.Average_with_unmapped_property_access_throws_meaningful_exception(Boolean async) line 1896
@ajcvickers ajcvickers added this to the Backlog milestone Apr 20, 2020
@ajcvickers ajcvickers modified the milestones: Backlog, 6.0.0 Nov 5, 2020
@smitpatel smitpatel removed the blocked label Aug 16, 2021
@smitpatel smitpatel removed this from the 6.0.0 milestone Aug 23, 2021
@ajcvickers ajcvickers added this to the Backlog milestone Aug 24, 2021
@ajcvickers ajcvickers modified the milestones: Backlog, 7.0.0 Nov 10, 2021
@ajcvickers ajcvickers added punted-for-7.0 Originally planned for the EF Core 7.0 (EF7) release, but moved out due to resource constraints. and removed propose-punt labels Jul 7, 2022
@ajcvickers ajcvickers modified the milestones: 7.0.0, Backlog Jul 7, 2022
@smitpatel smitpatel removed their assignment Sep 14, 2022
@maumar
Copy link
Contributor Author

maumar commented Dec 7, 2023

Same for mapped type with cast over it:

    public virtual Task Type_casting_inside_sum(bool async)
        => AssertSum(
            async,
            ss => ss.Set<OrderDetail>(),
            x => (decimal)x.Discount);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-cosmos area-query cosmos-query-refactor punted-for-6.0 punted-for-7.0 Originally planned for the EF Core 7.0 (EF7) release, but moved out due to resource constraints. type-bug
Projects
None yet
Development

No branches or pull requests

3 participants