Skip to content

Cosmos: cannot project owned entities in various scenarios #34350

Open

Description

query:

public virtual Task Json_projection_second_element_projected_before_owner_nested_as_well_as_root_AsNoTrackingWithIdentityResolution(bool async)
    => AssertQuery(
        async,
        ss => ss.Set<JsonEntityBasic>().Select(
            x => new
            {
                x.Id,
                Duplicate = x.OwnedReferenceRoot.OwnedReferenceBranch.OwnedCollectionLeaf[1],
                Original = x.OwnedReferenceRoot.OwnedReferenceBranch.OwnedCollectionLeaf,
                Parent = x.OwnedReferenceRoot.OwnedReferenceBranch,
                Owner = x
            }).AsNoTrackingWithIdentityResolution(),

exception:

Message: 
System.ArgumentException : Expression of type 'System.Collections.Generic.List`1[Microsoft.EntityFrameworkCore.TestModels.JsonQuery.JsonOwnedLeaf]' cannot be used for parameter of type 'System.Linq.IQueryable`1[Microsoft.EntityFrameworkCore.TestModels.JsonQuery.JsonOwnedLeaf]' of method 'Microsoft.EntityFrameworkCore.TestModels.JsonQuery.JsonOwnedLeaf ElementAt[JsonOwnedLeaf](System.Linq.IQueryable`1[Microsoft.EntityFrameworkCore.TestModels.JsonQuery.JsonOwnedLeaf], Int32)' (Parameter 'arg0')

  Stack Trace: 
ExpressionUtils.ValidateOneArgument(MethodBase method, ExpressionType nodeKind, Expression arguments, ParameterInfo pi, String methodParamName, String argumentParamName, Int32 index)
Expression.Call(Expression instance, MethodInfo method, Expression arg0, Expression arg1)
Expression.Call(Expression instance, MethodInfo method, IEnumerable`1 arguments)
CosmosProjectionBindingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression) line 635
CosmosProjectionBindingExpressionVisitor.Visit(Expression expression) line 141
CosmosProjectionBindingExpressionVisitor.VisitNew(NewExpression newExpression) line 683
CosmosProjectionBindingExpressionVisitor.Visit(Expression expression) line 107
CosmosProjectionBindingExpressionVisitor.Translate(SelectExpression selectExpression, Expression expression) line 76
CosmosQueryableMethodTranslatingExpressionVisitor.TranslateSelect(ShapedQueryExpression source, LambdaExpression selector) line 1027
QueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression) line 450
CosmosQueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression) line 247
QueryableMethodTranslatingExpressionVisitor.Translate(Expression expression) line 62
CosmosQueryableMethodTranslatingExpressionVisitor.Translate(Expression expression) line 153
QueryCompilationContext.CreateQueryExecutorExpression[TResult](Expression query) line 231
QueryCompilationContext.CreateQueryExecutor[TResult](Expression query) line 199
Database.CompileQuery[TResult](Expression query, Boolean async) line 68
QueryCompiler.CompileQueryCore[TResult](IDatabase database, Expression query, IModel model, Boolean async) line 127
<>c__DisplayClass11_0`1.<ExecuteCore>b__0() line 83
CompiledQueryCache.GetOrAddQuery[TResult](Object cacheKey, Func`1 compiler) line 66
QueryCompiler.ExecuteCore[TResult](Expression query, Boolean async, CancellationToken cancellationToken) line 79
QueryCompiler.Execute[TResult](Expression query) line 60
EntityQueryProvider.Execute[TResult](Expression expression) line 64
EntityQueryable`1.GetEnumerator() line 78
List`1.ctor(IEnumerable`1 collection)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions