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 : Compilation error for queries with optional navigation, client side method and parameter #7289

Closed
cherici-simone opened this issue Dec 21, 2016 · 3 comments
Assignees
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Milestone

Comments

@cherici-simone
Copy link

Hello, after migrate pur web api project to .net core 1.1 I run into a problem with a query that previously work correct.
This is the query:

var activityVersion = DbContext
			.ActivityVersions
			.Include(av=>av.Activity)
			.Include(av=>av.DeployedVersions)
			.Where(av => av.Activity.Name.Equals(serviceName, StringComparison.InvariantCultureIgnoreCase)
						&& av.Activity.ActivityType == Model.ActivityType.Service
						&& av.DeployedVersions.Any(dv => dv.Space.FullPath.Equals(servicePath, StringComparison.InvariantCultureIgnoreCase)))
			.OrderByDescending(ord => ord.Version)
			.FirstOrDefault();

Variable serviceName and servicePath are strings (the first is the action parameter and the second is a method variable) and Model.ActivityType.Service is an enum

The error is:
variable '__serviceName_0' of type 'System.String' referenced from scope '', but it is not defined

And here the full stack:
at System.Linq.Expressions.Compiler.VariableBinder.Reference(ParameterExpression node, VariableStorageKind storage) at System.Linq.Expressions.Compiler.VariableBinder.VisitParameter(ParameterExpression node) at System.Linq.Expressions.ExpressionVisitor.VisitArguments(IArgumentProvider nodes) at System.Linq.Expressions.ExpressionVisitor.VisitMethodCall(MethodCallExpression node) at System.Linq.Expressions.Compiler.VariableBinder.VisitUnary(UnaryExpression node) at System.Linq.Expressions.ExpressionVisitor.VisitBinary(BinaryExpression node) at System.Linq.Expressions.ExpressionVisitor.VisitConditional(ConditionalExpression node) at System.Linq.Expressions.ExpressionVisitor.Visit(ReadOnlyCollection1 nodes)
at System.Linq.Expressions.Compiler.VariableBinder.VisitBlock(BlockExpression node)
at System.Linq.Expressions.ExpressionVisitor.VisitBinary(BinaryExpression node)
at System.Linq.Expressions.ExpressionVisitor.VisitBinary(BinaryExpression node)
at System.Linq.Expressions.ExpressionVisitor.VisitBinary(BinaryExpression node)
at System.Linq.Expressions.ExpressionVisitor.Visit(ReadOnlyCollection1 nodes) at System.Linq.Expressions.Compiler.VariableBinder.VisitLambda[T](Expression1 node)
at System.Linq.Expressions.ExpressionVisitor.VisitArguments(IArgumentProvider nodes)
at System.Linq.Expressions.ExpressionVisitor.VisitMethodCall(MethodCallExpression node)
at System.Linq.Expressions.ExpressionVisitor.VisitArguments(IArgumentProvider nodes)
at System.Linq.Expressions.ExpressionVisitor.VisitMethodCall(MethodCallExpression node)
at System.Linq.Expressions.ExpressionVisitor.VisitArguments(IArgumentProvider nodes)
at System.Linq.Expressions.ExpressionVisitor.VisitMethodCall(MethodCallExpression node)
at System.Linq.Expressions.ExpressionVisitor.VisitArguments(IArgumentProvider nodes)
at System.Linq.Expressions.ExpressionVisitor.VisitMethodCall(MethodCallExpression node)
at System.Linq.Expressions.ExpressionVisitor.VisitArguments(IArgumentProvider nodes)
at System.Linq.Expressions.ExpressionVisitor.VisitMethodCall(MethodCallExpression node)
at System.Linq.Expressions.ExpressionVisitor.VisitArguments(IArgumentProvider nodes)
at System.Linq.Expressions.ExpressionVisitor.VisitMethodCall(MethodCallExpression node)
at System.Linq.Expressions.ExpressionVisitor.Visit(ReadOnlyCollection1 nodes) at System.Linq.Expressions.Compiler.VariableBinder.VisitLambda[T](Expression1 node)
at System.Linq.Expressions.Compiler.VariableBinder.Bind(LambdaExpression lambda)
at System.Linq.Expressions.Compiler.LambdaCompiler.Compile(LambdaExpression lambda, DebugInfoGenerator debugInfoGenerator)
at System.Linq.Expressions.Expression1.Compile() at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.CreateExecutorLambda[TResults]() at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.CreateQueryExecutor[TResult](QueryModel queryModel) at Microsoft.EntityFrameworkCore.Storage.Database.CompileQuery[TResult](QueryModel queryModel) at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQueryCore[TResult](Expression query, INodeTypeProvider nodeTypeProvider, IDatabase database, ILogger logger, Type contextType) at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass19_01.b__0()
at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQueryCore[TFunc](Object cacheKey, Func1 compiler) at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQuery[TResult](Object cacheKey, Func1 compiler)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQuery[TResult](Expression query)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute[TResult](Expression query)
at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.Execute[TResult](Expression expression)
at MRCS.SmartStrategySystem.WebApi.Controllers.ServicesController.

d__8.MoveNext() in C:\Users\Administrator\Source\vsonline\MRCS3\SmartStrategySystem\WebApiVNext\src\WebApi\Controllers\ServicesController.cs:line 73`

@divega divega added this to the 1.1.1 milestone Jan 6, 2017
@divega divega added the type-bug label Jan 6, 2017
@divega divega changed the title Error after migrating to .net core 1.1 Error after migrating to .NET core 1.1 Jan 13, 2017
@maumar maumar changed the title Error after migrating to .NET core 1.1 Query : Compilation error for queries with optional navigation, client side method and parameter Jan 31, 2017
maumar added a commit that referenced this issue Jan 31, 2017
…vigation, client side method and parameter

Problem was that DefaultQueryExpressionVisitor was not visiting extension expressions. During optional navigations we introduced NullConditional expressions to protect against null references - fix is to visit this expression as well.
@maumar
Copy link
Contributor

maumar commented Jan 31, 2017

@divega
Justification to include this in 1.1.1 release:

Impact: Medium. This is a regression introduced in 1.1.0 and was found by a customer.
Risk: Low. Fix is local, implementing a missing Visit method on one visitor.

maumar added a commit that referenced this issue Feb 1, 2017
…vigation, client side method and parameter

Problem was that DefaultQueryExpressionVisitor was not visiting extension expressions. During optional navigations we introduced NullConditional expressions to protect against null references - fix is to visit this expression as well.
@Eilon
Copy link
Member

Eilon commented Feb 8, 2017

This patch bug is approved. Please use the normal code review process w/ a PR and make sure the fix is in the correct branch, then close the bug and mark it as done.

maumar added a commit that referenced this issue Feb 9, 2017
…vigation, client side method and parameter

Problem was that DefaultQueryExpressionVisitor was not visiting extension expressions. During optional navigations we introduced NullConditional expressions to protect against null references - fix is to visit this expression as well.
maumar added a commit that referenced this issue Feb 10, 2017
…vigation, client side method and parameter

Problem was that DefaultQueryExpressionVisitor was not visiting extension expressions. During optional navigations we introduced NullConditional expressions to protect against null references - fix is to visit this expression as well.
@maumar
Copy link
Contributor

maumar commented Feb 10, 2017

fixed in 2b1edbf

@maumar maumar closed this as completed Feb 10, 2017
@maumar maumar added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Feb 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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

5 participants