Skip to content

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

Open

Description

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions