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

Query: NRE when projecting non-mapped property from SelectMany #17763

Closed
maumar opened this issue Sep 11, 2019 · 3 comments
Closed

Query: NRE when projecting non-mapped property from SelectMany #17763

maumar opened this issue Sep 11, 2019 · 3 comments
Assignees
Labels
area-query closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Milestone

Comments

@maumar
Copy link
Contributor

maumar commented Sep 11, 2019

query:

cs.SelectMany(c => c.Orders.Select(o => new { OrderProperty = o.ShipName, CustomerProperty = c.ContactName }))

exception:

 Message: 
    System.NullReferenceException : Object reference not set to an instance of an object.
  Stack Trace: 
    at MemberAccessShiftingExpressionVisitor.VisitExtension(Expression node) in QueryableMethodTranslatingExpressionVisitor.cs line: 511
    at Expression.Accept(ExpressionVisitor visitor)
    at ExpressionVisitor.Visit(Expression node)
    at EntityShaperExpression.VisitChildren(ExpressionVisitor visitor) in EntityShaperExpression.cs line: 25
    at ExpressionVisitor.VisitExtension(Expression node)
    at MemberAccessShiftingExpressionVisitor.VisitExtension(Expression node) in QueryableMethodTranslatingExpressionVisitor.cs line: 517
    at Expression.Accept(ExpressionVisitor visitor)
    at ExpressionVisitor.Visit(Expression node)
    at ExpressionVisitor.VisitMember(MemberExpression node)
    at MemberExpression.Accept(ExpressionVisitor visitor)
    at ExpressionVisitor.Visit(Expression node)
    at ExpressionVisitorUtils.VisitArguments(ExpressionVisitor visitor, IArgumentProvider nodes)
    at ExpressionVisitor.VisitNew(NewExpression node)
    at NewExpression.Accept(ExpressionVisitor visitor)
    at ExpressionVisitor.Visit(Expression node)
    at QueryableMethodTranslatingExpressionVisitor.CombineShapers(Expression queryExpression, Expression outerShaper, Expression innerShaper, Type transparentIdentifierType) in QueryableMethodTranslatingExpressionVisitor.cs line: 489
    at QueryableMethodTranslatingExpressionVisitor.TranslateResultSelectorForJoin(ShapedQueryExpression outer, LambdaExpression resultSelector, Expression innerShaper, Type transparentIdentifierType) in QueryableMethodTranslatingExpressionVisitor.cs line: 459
    at RelationalQueryableMethodTranslatingExpressionVisitor.TranslateSelectMany(ShapedQueryExpression source, LambdaExpression collectionSelector, LambdaExpression resultSelector) in RelationalQueryableMethodTranslatingExpressionVisitor.cs line: 778
    at QueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression) in QueryableMethodTranslatingExpressionVisitor.cs line: 351
    at RelationalQueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression) in RelationalQueryableMethodTranslatingExpressionVisitor.cs line: 72
    at MethodCallExpression.Accept(ExpressionVisitor visitor)
    at ExpressionVisitor.Visit(Expression node)
    at QueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression) in QueryableMethodTranslatingExpressionVisitor.cs line: 58
    at RelationalQueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression) in RelationalQueryableMethodTranslatingExpressionVisitor.cs line: 72
    at MethodCallExpression.Accept(ExpressionVisitor visitor)
    at ExpressionVisitor.Visit(Expression node)
    at QueryCompilationContext.CreateQueryExecutor[TResult](Expression query) in QueryCompilationContext.cs line: 68
    at Database.CompileQuery[TResult](Expression query, Boolean async) in Database.cs line: 71
    at QueryCompiler.CompileQueryCore[TResult](IDatabase database, Expression query, IModel model, Boolean async) in QueryCompiler.cs line: 106
    at <>c__DisplayClass12_0`1.<ExecuteAsync>b__0() in QueryCompiler.cs line: 137
    at CompiledQueryCache.GetOrAddQueryCore[TFunc](Object cacheKey, Func`1 compiler) in CompiledQueryCache.cs line: 84
    at CompiledQueryCache.GetOrAddQuery[TResult](Object cacheKey, Func`1 compiler) in CompiledQueryCache.cs line: 59
    at QueryCompiler.ExecuteAsync[TResult](Expression query, CancellationToken cancellationToken) in QueryCompiler.cs line: 133
    at EntityQueryProvider.ExecuteAsync[TResult](Expression expression, CancellationToken cancellationToken) in EntityQueryProvider.cs line: 98
    at EntityQueryable`1.GetAsyncEnumerator(CancellationToken cancellationToken) in EntityQueryable`.cs line: 112
    at ConfiguredCancelableAsyncEnumerable`1.GetAsyncEnumerator()
    at EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken) in EntityFrameworkQueryableExtensions.cs line: 2019
    at EntityFrameworkQueryableExtensions.ToArrayAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken) in EntityFrameworkQueryableExtensions.cs line: 2050
    at QueryAsserter`1.AssertQuery[TItem1](Func`2 actualQuery, Func`2 expectedQuery, Func`2 elementSorter, Action`2 elementAsserter, Boolean assertOrder, Int32 entryCount, Boolean isAsync, String testMethodName) in QueryAsserter.cs line: 350
    at SimpleQuerySqlServerTest.SelectMany_with_collection_being_correlated_subquery_which_references_non_mapped_properties_from_inner_and_outer_entity(Boolean isAsync) in SimpleQuerySqlServerTest.Select.cs line: 1085
    at --- End of stack trace from previous location where exception was thrown ---

projectionBindingExpression.ProjectionMember is null

@divega
Copy link
Contributor

divega commented Sep 11, 2019

@maumar to check if this affects simpler queries.

@smitpatel
Copy link
Member

This would happen when running Join translation after one side has client eval. We should throw appropriately in advance.

@maumar
Copy link
Contributor Author

maumar commented Sep 11, 2019

i verified simple projection works

@maumar maumar removed their assignment Sep 11, 2019
@divega divega added this to the Backlog milestone Sep 16, 2019
@smitpatel smitpatel added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Jun 10, 2020
@smitpatel smitpatel self-assigned this Jun 10, 2020
@smitpatel smitpatel modified the milestones: Backlog, 5.0.0 Jun 10, 2020
smitpatel added a commit that referenced this issue Jun 10, 2020
smitpatel added a commit that referenced this issue Jun 10, 2020
@ajcvickers ajcvickers modified the milestones: 5.0.0, 5.0.0-preview7 Jun 22, 2020
@ajcvickers ajcvickers modified the milestones: 5.0.0-preview7, 5.0.0 Nov 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-query closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Projects
None yet
Development

No branches or pull requests

4 participants