Skip to content

Query: enable synthesizing rows from list/array of constant values to allow more queries to be server-evaluated #6660

@felipepessoto

Description

@felipepessoto

Steps to reproduce

string[] termsSplit = terms.Split(' ');
IQueryable<Post> query2 = 
    from post in db.Posts
    where termsSplit.Any(x => post.Content.Contains(x))
    select post;

The issue

query2.Count() causes a NullReferenceException. But it shouldn't be evalute that query at client side:

System.NullReferenceException was unhandled by user code
  HResult=-2147467261
  Message=Object reference not set to an instance of an object.
  Source=Anonymously Hosted DynamicMethods Assembly
  StackTrace:
       at lambda_method(Closure , String )
       at System.Linq.Enumerable.WhereArrayIterator`1.MoveNext()
       at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source)
       at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
       at System.Linq.Enumerable.Count[TSource](IEnumerable`1 source)
       at lambda_method(Closure , QueryContext )
       at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass19_1`1.<CompileQuery>b__1(QueryContext qc)
       at System.Linq.Queryable.Count[TSource](IQueryable`1 source)
       at FujiyBlog.Web.Controllers.SearchController.Index(Nullable`1 page, String terms) in D:\Meus Arquivos\Desenvolvimento\Projetos\FujiyBlog\src\FujiyBlog.Web\Controllers\SearchController.cs:line 42
       at lambda_method(Closure , Object , Object[] )
       at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeActionFilterAsync>d__28.MoveNext()
  InnerException: 

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions