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

NRE in 6.3.0-preview5 on .NET Core with parameterized StartsWith() #860

Closed
roji opened this issue May 20, 2019 · 2 comments
Closed

NRE in 6.3.0-preview5 on .NET Core with parameterized StartsWith() #860

roji opened this issue May 20, 2019 · 2 comments

Comments

@roji
Copy link
Member

roji commented May 20, 2019

When using EF6 6.3.0-preview5-19254-05 in an application targeting netcoreapp3.0, an NRE is produced from the following code:

var x = "X";
var blogs = ctx.Blogs.Where(b => b.Name.StartsWith(x)).ToList();

Stack trace:

Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
   at System.Linq.Expressions.Compiler.LambdaCompiler.EmitMethodCall(Expression obj, MethodInfo method, IArgumentProvider methodCallExpr, CompilationFlags flags)
   at System.Linq.Expressions.Compiler.LambdaCompiler.EmitExpression(Expression node, CompilationFlags flags)
   at System.Linq.Expressions.Compiler.LambdaCompiler.EmitInstance(Expression instance, Type& type)
   at System.Linq.Expressions.Compiler.LambdaCompiler.EmitMemberExpression(Expression expr)
   at System.Linq.Expressions.Compiler.LambdaCompiler.EmitExpression(Expression node, CompilationFlags flags)
   at System.Linq.Expressions.Compiler.LambdaCompiler.EmitLambdaBody(CompilerScope parent, Boolean inlined, CompilationFlags flags)
   at System.Linq.Expressions.Compiler.LambdaCompiler.EmitLambdaBody()
   at System.Linq.Expressions.Compiler.LambdaCompiler.Compile(LambdaExpression lambda)
   at System.Data.Entity.Core.Objects.ELinq.QueryParameterExpression.EvaluateParameter(Object[] arguments)
   at System.Data.Entity.Core.Objects.ELinq.ELinqQueryState.GetExecutionPlan(Nullable`1 forMergeOption)
   at System.Data.Entity.Core.Objects.ObjectQuery`1.<>c__DisplayClass41_0.<GetResults>b__1()
   at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)
   at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func`1 operation)
   at System.Data.Entity.Core.Objects.ObjectQuery`1.<System.Collections.Generic.IEnumerable<T>.GetEnumerator>b__31_0()
   at System.Data.Entity.Internal.LazyEnumerator`1.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at Test.Program.Main(String[] args) in /home/roji/projects/Test/Program.cs:line 19
@ajcvickers
Copy link
Member

/cc @bricelam

@bricelam bricelam self-assigned this May 20, 2019
@bricelam
Copy link
Contributor

I'm still digging into this, but it looks like a bug in .NET Core's expression compiler. It will affect any query that translates to LIKE. Trying to create a simple repro...

@bricelam bricelam added this to the 6.3.0 milestone May 31, 2019
bricelam added a commit to bricelam/ef6 that referenced this issue Jun 5, 2019
@ajcvickers ajcvickers modified the milestones: 6.3.0, 6.3.0-preview7 Jul 2, 2019
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

3 participants