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

Expression issue with ef core 3.0 #18416

Closed
WeihanLi opened this issue Oct 17, 2019 · 2 comments
Closed

Expression issue with ef core 3.0 #18416

WeihanLi opened this issue Oct 17, 2019 · 2 comments

Comments

@WeihanLi
Copy link
Contributor

seemed same issue with #18333, but seemed not duplicate with #17791(still failed with version 3.1.0-preview1.19506.2)

Core code here:

// Core code
Expression<Func<TestEntity, bool>> whereExpression = e => true;
whereExpression = And(whereExpression, e => e.Id > 0);

var data = db.TestEntities.Where(whereExpression).ToArray(); // break here

exception below:

System.InvalidOperationException: The LINQ expression 'Where<TestEntity>(
    source: DbSet<TestEntity>,
    predicate: (t) => True && Invoke(e => (e.Id > 0), t[TestEntity])
)' could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to either AsEnumerable(), AsAsyncEnumerable(), ToList(), or ToListAsync(). See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.
   at Microsoft.EntityFrameworkCore.Query.QueryableMethodTranslatingExpressionVisitor.<VisitMethodCall>g__CheckTranslated|8_0(ShapedQueryExpression translated, <>c__DisplayClass8_0& )
   at Microsoft.EntityFrameworkCore.Query.QueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
   at Microsoft.EntityFrameworkCore.Query.RelationalQueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
   at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor)
   at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
   at Microsoft.EntityFrameworkCore.Query.QueryCompilationContext.CreateQueryExecutor[TResult](Expression query)
   at Microsoft.EntityFrameworkCore.Storage.Database.CompileQuery[TResult](Expression query, Boolean async)
   at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQueryCore[TResult](IDatabase database, Expression query, IModel model, Boolean async)
   at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass9_0`1.<Execute>b__0()
   at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQueryCore[TFunc](Object cacheKey, Func`1 compiler)
   at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQuery[TResult](Object cacheKey, Func`1 compiler)
   at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute[TResult](Expression query)
   at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.Execute[TResult](Expression expression)
   at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable`1.GetEnumerator()
   at System.Collections.Generic.LargeArrayBuilder`1.AddRange(IEnumerable`1 items)
   at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at EFCore3_0ExpressionIssueDemo.Program.Main(String[] args) in C:\projects\test\EFCore3_0ExpressionIssueDemo\Program.cs:line 49

Steps to reproduce

I'd uploaded a demo here
EFCore3_0ExpressionIssueDemo.zip

Further technical details

EF Core version: 3.0.0/3.1.0-preview1.19506.2
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET Core 3.0
Operating system: Windows 10
IDE: Visual Studio 2019 16.3.5

@smitpatel
Copy link
Contributor

Duplicate of #17791

#17791 is fixed in 3.1.0-preview2 not in preview1.

@WeihanLi
Copy link
Contributor Author

Could you please publish a nuget package? could not found 3.1.0-preview2 even in daily build packages,
and when'll preview 2 release?

@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

3 participants