Regression in 6.2.0: Contains(...) gives NullReferenceException (works in 6.1.3)
See original GitHub issueIn 6.2.0 a query containing .Contains(…) throws a NullReferenceException when performing .Count() on the query.
For example:
using (var pdc = new DbContext())
{
var q = pdc.Books.Where(o => o.Title.Contains("search"));
q.Count();
}
This code works in 6.1.3 but throws the below stacktrace in 6.2.0:
System.NullReferenceException: Object reference not set to an instance of an object
at System.Linq.Expressions.Compiler.LambdaCompiler.EmitMethodCall (System.Linq.Expressions.Expression obj, System.Reflection.MethodInfo method, System.Linq.Expressions.IArgumentProvider methodCallExpr, System.Linq.Expressions.Compiler.LambdaCompiler+CompilationFlags flags) [0x00002] in <521f3fe476f34ea88748e97b3b984d05>:0
at System.Linq.Expressions.Compiler.LambdaCompiler.EmitInvocationExpression (System.Linq.Expressions.Expression expr, System.Linq.Expressions.Compiler.LambdaCompiler+CompilationFlags flags) [0x0002d] in <521f3fe476f34ea88748e97b3b984d05>:0
at System.Linq.Expressions.Compiler.LambdaCompiler.EmitExpression (System.Linq.Expressions.Expression node, System.Linq.Expressions.Compiler.LambdaCompiler+CompilationFlags flags) [0x00263] in <521f3fe476f34ea88748e97b3b984d05>:0
at System.Linq.Expressions.Compiler.LambdaCompiler.EmitExpression (System.Linq.Expressions.Expression node) [0x00000] in <521f3fe476f34ea88748e97b3b984d05>:0
at System.Linq.Expressions.Compiler.LambdaCompiler.EmitInstance (System.Linq.Expressions.Expression instance, System.Type& type) [0x00035] in <521f3fe476f34ea88748e97b3b984d05>:0
at System.Linq.Expressions.Compiler.LambdaCompiler.EmitMemberExpression (System.Linq.Expressions.Expression expr) [0x00018] in <521f3fe476f34ea88748e97b3b984d05>:0
at System.Linq.Expressions.Compiler.LambdaCompiler.EmitExpression (System.Linq.Expressions.Expression node, System.Linq.Expressions.Compiler.LambdaCompiler+CompilationFlags flags) [0x00288] in <521f3fe476f34ea88748e97b3b984d05>:0
at System.Linq.Expressions.Compiler.LambdaCompiler.EmitLambdaBody (System.Linq.Expressions.Compiler.CompilerScope parent, System.Boolean inlined, System.Linq.Expressions.Compiler.LambdaCompiler+CompilationFlags flags) [0x00085] in <521f3fe476f34ea88748e97b3b984d05>:0
at System.Linq.Expressions.Compiler.LambdaCompiler.EmitLambdaBody () [0x0001a] in <521f3fe476f34ea88748e97b3b984d05>:0
at System.Linq.Expressions.Compiler.LambdaCompiler.Compile (System.Linq.Expressions.LambdaExpression lambda) [0x0000d] in <521f3fe476f34ea88748e97b3b984d05>:0
at System.Linq.Expressions.LambdaExpression.Compile (System.Boolean preferInterpretation) [0x00000] in <521f3fe476f34ea88748e97b3b984d05>:0
at System.Linq.Expressions.LambdaExpression.Compile () [0x00000] in <521f3fe476f34ea88748e97b3b984d05>:0
at System.Data.Entity.Core.Objects.ELinq.QueryParameterExpression.EvaluateParameter (System.Object[] arguments) [0x0008d] in <b7b192e5a05f4f14a14aa0d5b14aeeeb>:0
at System.Data.Entity.Core.Objects.ELinq.ELinqQueryState.GetExecutionPlan (System.Nullable`1[T] forMergeOption) [0x002e5] in <b7b192e5a05f4f14a14aa0d5b14aeeeb>:0
at System.Data.Entity.Core.Objects.ObjectQuery`1+<>c__DisplayClass7[T].<GetResults>b__6 () [0x0000b] in <b7b192e5a05f4f14a14aa0d5b14aeeeb>:0
at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T] (System.Func`1[TResult] func, System.Data.Entity.Infrastructure.IDbExecutionStrategy executionStrategy, System.Boolean startLocalTransaction, System.Boolean releaseConnectionOnSuccess) [0x0008a] in <b7b192e5a05f4f14a14aa0d5b14aeeeb>:0
at System.Data.Entity.Core.Objects.ObjectQuery`1+<>c__DisplayClass7[T].<GetResults>b__5 () [0x00033] in <b7b192e5a05f4f14a14aa0d5b14aeeeb>:0
at System.Data.Entity.Infrastructure.DefaultExecutionStrategy.Execute[TResult] (System.Func`1[TResult] operation) [0x00000] in <b7b192e5a05f4f14a14aa0d5b14aeeeb>:0
at System.Data.Entity.Core.Objects.ObjectQuery`1[T].GetResults (System.Nullable`1[T] forMergeOption) [0x00093] in <b7b192e5a05f4f14a14aa0d5b14aeeeb>:0
at System.Data.Entity.Core.Objects.ObjectQuery`1[T].<System.Collections.Generic.IEnumerable<T>.GetEnumerator>b__0 () [0x00000] in <b7b192e5a05f4f14a14aa0d5b14aeeeb>:0
at System.Data.Entity.Internal.LazyEnumerator`1[T].MoveNext () [0x00008] in <b7b192e5a05f4f14a14aa0d5b14aeeeb>:0
at System.Linq.Enumerable.Single[TSource] (System.Collections.Generic.IEnumerable`1[T] source) [0x0003d] in <521f3fe476f34ea88748e97b3b984d05>:0
at System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.<GetElementFunction>b__3[TResult] (System.Collections.Generic.IEnumerable`1[T] sequence) [0x00000] in <b7b192e5a05f4f14a14aa0d5b14aeeeb>:0
at System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.ExecuteSingle[TResult] (System.Collections.Generic.IEnumerable`1[T] query, System.Linq.Expressions.Expression queryRoot) [0x00006] in <b7b192e5a05f4f14a14aa0d5b14aeeeb>:0
at System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.System.Linq.IQueryProvider.Execute[TResult] (System.Linq.Expressions.Expression expression) [0x00014] in <b7b192e5a05f4f14a14aa0d5b14aeeeb>:0
at System.Data.Entity.Internal.Linq.DbQueryProvider.Execute[TResult] (System.Linq.Expressions.Expression expression) [0x00022] in <b7b192e5a05f4f14a14aa0d5b14aeeeb>:0
at System.Linq.Queryable.Count[TSource] (System.Linq.IQueryable`1[T] source) [0x0002f] in <521f3fe476f34ea88748e97b3b984d05>:0
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Past Releases of Entity Framework - EF6
The EF 6.1.3 runtime was released to NuGet in October of 2015. This release contains only fixes to high-priority defects and regressions ......
Read more >regressions.lists.linux.dev archive mirror
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as...
Read more >Issues for Webform
"Autofocus the first element" POST the form when a Card don't have any fillable ... Duplicated default submit button, Needs work, Normal, Bug...
Read more >webform 6.2.0-beta6
js conditional operation returns the same value whether the condition is "true" or "false"; #3352187 by jrockowitz: "Autofocus the first element ...
Read more >Release Notes for Flyway Engine
The SQLite driver shipped with the Flyway CLI has been updated to 3.41.2.2 to ... Help output for 'check' no longer returns 'null'...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Adding .ToList() does not solve the problem at all. The problem happens before that, in the expression evaluator.
This is still a vexing problem. Any other recommendations for a workaround?
Closing this as external as the only repro we have points to it being an issue with the mono expression compiler.