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: Rewrite Entity Equality #15588

Closed
smitpatel opened this issue May 2, 2019 · 3 comments · Fixed by #15920
Closed

Query: Rewrite Entity Equality #15588

smitpatel opened this issue May 2, 2019 · 3 comments · Fixed by #15920
Assignees
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-enhancement
Milestone

Comments

@smitpatel
Copy link
Contributor

No description provided.

@smitpatel smitpatel mentioned this issue May 2, 2019
22 tasks
@ajcvickers ajcvickers added this to the 3.0.0 milestone May 3, 2019
roji added a commit to roji/efcore that referenced this issue Jun 3, 2019
New implementation of entity equality rewriter, which follows exact
entity (and anonymous) from roots to the comparison expression, for
more precise rewriting.

Closes dotnet#15588
roji added a commit that referenced this issue Jun 3, 2019
New implementation of entity equality rewriter, which follows exact
entity (and anonymous) from roots to the comparison expression, for
more precise rewriting.

Closes #15588
@roji roji mentioned this issue Jun 3, 2019
5 tasks
roji added a commit that referenced this issue Jun 4, 2019
New implementation of entity equality rewriter, which follows exact
entity (and anonymous) from roots to the comparison expression, for
more precise rewriting.

Closes #15588
roji added a commit to roji/efcore that referenced this issue Jun 4, 2019
New implementation of entity equality rewriter, which follows exact
entity (and anonymous) from roots to the comparison expression, for
more precise rewriting.

Closes dotnet#15588
roji added a commit that referenced this issue Jun 4, 2019
New implementation of entity equality rewriter, which follows exact
entity (and anonymous) from roots to the comparison expression, for
more precise rewriting.

Closes #15588
roji added a commit that referenced this issue Jun 6, 2019
New implementation of entity equality rewriter, which follows exact
entity (and anonymous) from roots to the comparison expression, for
more precise rewriting.

Closes #15588
roji added a commit that referenced this issue Jun 6, 2019
New implementation of entity equality rewriter, which follows exact
entity (and anonymous) from roots to the comparison expression, for
more precise rewriting.

Closes #15588
@roji roji changed the title Query: Rewrite EntityEqualityRewrite Query: Rewrite Entity Equality Jun 20, 2019
@ajcvickers ajcvickers added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Jul 2, 2019
@ajcvickers ajcvickers modified the milestones: 3.0.0, 3.0.0-preview7 Jul 2, 2019
@Pentadome
Copy link

Is it possible to use ==null in a Where method? If not, is there an alternative to do this? I get "Null TypeMapping in Sql Tree" error when I do.

@alexk8
Copy link

alexk8 commented Jul 24, 2019

This issue is considered to be closed in preview7, but in preview7 I still encounter an error, which is now a bit different
(original issue comment )
code

context.children.Where(x => x.parentRef.id==aParentEntity.id).ToList(); //fine
context.children.Where(x => x.parentRef==aParentEntity).ToList(); // error
// context.Entry(aParentEntity).State == Unchanged

InvalidOperationException: Operation is not valid due to the current state of the object

Microsoft.EntityFrameworkCore.Relational.Query.Pipeline.RelationalSqlTranslatingExpressionVisitor.BindProperty(Expression source, string propertyName)
Microsoft.EntityFrameworkCore.Relational.Query.Pipeline.RelationalSqlTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor)
Microsoft.EntityFrameworkCore.Relational.Query.Pipeline.RelationalSqlTranslatingExpressionVisitor.VisitBinary(BinaryExpression binaryExpression)
Microsoft.EntityFrameworkCore.SqlServer.Query.Pipeline.SqlServerSqlTranslatingExpressionVisitor.VisitBinary(BinaryExpression binaryExpression)
System.Linq.Expressions.BinaryExpression.Accept(ExpressionVisitor visitor)
Microsoft.EntityFrameworkCore.Relational.Query.Pipeline.RelationalSqlTranslatingExpressionVisitor.Translate(Expression expression)
Microsoft.EntityFrameworkCore.Relational.Query.Pipeline.RelationalQueryableMethodTranslatingExpressionVisitor.TranslateExpression(Expression expression)
Microsoft.EntityFrameworkCore.Relational.Query.Pipeline.RelationalQueryableMethodTranslatingExpressionVisitor.TranslateLambdaExpression(ShapedQueryExpression shapedQueryExpression, LambdaExpression lambdaExpression)
Microsoft.EntityFrameworkCore.Relational.Query.Pipeline.RelationalQueryableMethodTranslatingExpressionVisitor.TranslateWhere(ShapedQueryExpression source, LambdaExpression predicate)
Microsoft.EntityFrameworkCore.Query.Pipeline.QueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
Microsoft.EntityFrameworkCore.Relational.Query.Pipeline.RelationalQueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor)
Microsoft.EntityFrameworkCore.Query.Pipeline.QueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
Microsoft.EntityFrameworkCore.Relational.Query.Pipeline.RelationalQueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor)
Microsoft.EntityFrameworkCore.Query.Pipeline.QueryCompilationContext.CreateQueryExecutor<TResult>(Expression query)
Microsoft.EntityFrameworkCore.Storage.Database.CompileQuery<TResult>(Expression query, bool async)
Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQueryCore<TResult>(IDatabase database, Expression query, IModel model, bool async)
Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler+<>c__DisplayClass9_0<TResult>.<Execute>b__0()
Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQueryCore<TFunc>(object cacheKey, Func<Func<QueryContext, TFunc>> compiler)
Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQuery<TResult>(object cacheKey, Func<Func<QueryContext, TResult>> compiler)
Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute<TResult>(Expression query)
Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.Execute<TResult>(Expression expression)
Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable<TResult>.GetEnumerator()
System.Collections.Generic.List<T>..ctor(IEnumerable<T> collection)
System.Linq.Enumerable.ToList<TSource>(IEnumerable<TSource> source)

Entity Framework Core 3.0.0-preview7.19362.6

@smitpatel
Copy link
Contributor Author

@alexk8 - Since your query is using local variable in equality, the issue you are hitting is #15855. It is fixed in nightly builds and will be released in preview8.

@ajcvickers ajcvickers modified the milestones: 3.0.0-preview7, 3.0.0 Nov 11, 2019
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-enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants