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: "Null TypeMapping in Sql Tree" for contains query with List parameter #15851

Closed
maumar opened this issue May 30, 2019 · 6 comments
Closed

Comments

@maumar
Copy link
Contributor

maumar commented May 30, 2019

query:

var tags = context.Tags.Select(t => (Guid?)t.Id).ToList();

                var gears = context.Gears
                    .Where(g => g.Tag != null && tags.Contains(g.Tag.Id))
                    .ToList();

exception:

System.InvalidOperationException : Null TypeMapping in Sql Tree

D:\git\EntityFrameworkCore\src\EFCore.Relational\Query\PipeLine\RelationalSqlTranslatingExpressionVisitor.cs(72,0): at Microsoft.EntityFrameworkCore.Relational.Query.Pipeline.RelationalSqlTranslatingExpressionVisitor.SqlTypeMappingVerifyingExpressionVisitor.VisitExtension(Expression node)
   at System.Linq.Expressions.Expression.Accept(ExpressionVisitor visitor)
D:\git\EntityFrameworkCore\src\EFCore.Relational\Query\PipeLine\SqlExpressions\SqlUnaryExpression.cs(55,0): at Microsoft.EntityFrameworkCore.Relational.Query.Pipeline.SqlExpressions.SqlUnaryExpression.VisitChildren(ExpressionVisitor visitor)
   at System.Linq.Expressions.ExpressionVisitor.VisitExtension(Expression node)
D:\git\EntityFrameworkCore\src\EFCore.Relational\Query\PipeLine\RelationalSqlTranslatingExpressionVisitor.cs(74,0): at Microsoft.EntityFrameworkCore.Relational.Query.Pipeline.RelationalSqlTranslatingExpressionVisitor.SqlTypeMappingVerifyingExpressionVisitor.VisitExtension(Expression node)
   at System.Linq.Expressions.Expression.Accept(ExpressionVisitor visitor)
D:\git\EntityFrameworkCore\src\EFCore.Relational\Query\PipeLine\SqlExpressions\SqlBinaryExpression.cs(80,0): at Microsoft.EntityFrameworkCore.Relational.Query.Pipeline.SqlExpressions.SqlBinaryExpression.VisitChildren(ExpressionVisitor visitor)
   at System.Linq.Expressions.ExpressionVisitor.VisitExtension(Expression node)
D:\git\EntityFrameworkCore\src\EFCore.Relational\Query\PipeLine\RelationalSqlTranslatingExpressionVisitor.cs(74,0): at Microsoft.EntityFrameworkCore.Relational.Query.Pipeline.RelationalSqlTranslatingExpressionVisitor.SqlTypeMappingVerifyingExpressionVisitor.VisitExtension(Expression node)
   at System.Linq.Expressions.Expression.Accept(ExpressionVisitor visitor)
D:\git\EntityFrameworkCore\src\EFCore.Relational\Query\PipeLine\SqlExpressions\SqlBinaryExpression.cs(79,0): at Microsoft.EntityFrameworkCore.Relational.Query.Pipeline.SqlExpressions.SqlBinaryExpression.VisitChildren(ExpressionVisitor visitor)
   at System.Linq.Expressions.ExpressionVisitor.VisitExtension(Expression node)
D:\git\EntityFrameworkCore\src\EFCore.Relational\Query\PipeLine\RelationalSqlTranslatingExpressionVisitor.cs(74,0): at Microsoft.EntityFrameworkCore.Relational.Query.Pipeline.RelationalSqlTranslatingExpressionVisitor.SqlTypeMappingVerifyingExpressionVisitor.VisitExtension(Expression node)
   at System.Linq.Expressions.Expression.Accept(ExpressionVisitor visitor)
D:\git\EntityFrameworkCore\src\EFCore.Relational\Query\PipeLine\RelationalSqlTranslatingExpressionVisitor.cs(56,0): at Microsoft.EntityFrameworkCore.Relational.Query.Pipeline.RelationalSqlTranslatingExpressionVisitor.Translate(Expression expression)
D:\git\EntityFrameworkCore\src\EFCore.Relational\Query\PipeLine\RelationalQueryableMethodTranslatingExpressionVisitor.cs(824,0): at Microsoft.EntityFrameworkCore.Relational.Query.Pipeline.RelationalQueryableMethodTranslatingExpressionVisitor.TranslateExpression(Expression expression)
D:\git\EntityFrameworkCore\src\EFCore.Relational\Query\PipeLine\RelationalQueryableMethodTranslatingExpressionVisitor.cs(832,0): at Microsoft.EntityFrameworkCore.Relational.Query.Pipeline.RelationalQueryableMethodTranslatingExpressionVisitor.TranslateLambdaExpression(ShapedQueryExpression shapedQueryExpression, LambdaExpression lambdaExpression)
D:\git\EntityFrameworkCore\src\EFCore.Relational\Query\PipeLine\RelationalQueryableMethodTranslatingExpressionVisitor.cs(811,0): at Microsoft.EntityFrameworkCore.Relational.Query.Pipeline.RelationalQueryableMethodTranslatingExpressionVisitor.TranslateWhere(ShapedQueryExpression source, LambdaExpression predicate)
D:\git\EntityFrameworkCore\src\EFCore\Query\Pipeline\QueryableMethodTranslatingExpressionVisitor.cs(423,0): at Microsoft.EntityFrameworkCore.Query.Pipeline.QueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
   at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor)
D:\git\EntityFrameworkCore\src\EFCore\Query\Pipeline\QueryableMethodTranslatingExpressionVisitor.cs(31,0): at Microsoft.EntityFrameworkCore.Query.Pipeline.QueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
   at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor)
D:\git\EntityFrameworkCore\src\EFCore\Query\Pipeline\QueryCompilationContext2.cs(61,0): at Microsoft.EntityFrameworkCore.Query.Pipeline.QueryCompilationContext2.CreateQueryExecutor[TResult](Expression query)
D:\git\EntityFrameworkCore\src\EFCore\Storage\Database.cs(97,0): at Microsoft.EntityFrameworkCore.Storage.Database.CompileQuery2[TResult](Expression query, Boolean async)
D:\git\EntityFrameworkCore\src\EFCore\Query\Internal\QueryCompiler.cs(118,0): at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQueryCore[TResult](IDatabase database, Expression query, IModel model, Boolean async)
D:\git\EntityFrameworkCore\src\EFCore\Query\Internal\QueryCompiler.cs(107,0): at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass9_0`1.<Execute>b__0()
D:\git\EntityFrameworkCore\src\EFCore\Query\Internal\CompiledQueryCache.cs(84,0): at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQueryCore[TFunc](Object cacheKey, Func`1 compiler)
D:\git\EntityFrameworkCore\src\EFCore\Query\Internal\CompiledQueryCache.cs(59,0): at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQuery[TResult](Object cacheKey, Func`1 compiler)
D:\git\EntityFrameworkCore\src\EFCore\Query\Internal\QueryCompiler.cs(103,0): at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute[TResult](Expression query)
D:\git\EntityFrameworkCore\src\EFCore\Query\Internal\EntityQueryProvider.cs(80,0): at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.Execute[TResult](Expression expression)
D:\git\EntityFrameworkCore\src\EFCore\Query\Internal\EntityQueryable`.cs(93,0): at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable`1.GetEnumerator()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)

@smitpatel
Copy link
Contributor

Likely entity equality rewrite.

@roji
Copy link
Member

roji commented May 30, 2019

Yeah, this is the kind of query that is working now in my PR branch.

@maumar
Copy link
Contributor Author

maumar commented May 30, 2019

verified that entity equality is the issue here, closing as dupe of #15588

@clockwiseq
Copy link

This is not resolved and was not "fixed" in #15588. I am still experiencing this issue in 3.1

@clockwiseq
Copy link

Offending code:

context.OpenRequests.Where(par => orq.OwnerId == Employee.Id && determinations.Contains(orq.Determination.Name).OrderBy(orq=> orq.FollowUpDate).ThenBy(orq=> orq.CreateDate)

@roji
Copy link
Member

roji commented Dec 19, 2019

@clockwiseq can you please open a new issue with a runnable code sample?

@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants