You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This query thows an exception when materialized:
var records = Context.Set().Where(x => x.Customer.IsVip.ToString().Contains(value));
where IsVip is a boolean field.
It happens when using EF Core 3.0 Preview 8. But it worked until EF Core 3.0 Preview 5.
Exception message:
Operation is not valid due to the current state of the object.
[EFCoreTest.zip](https://github.com/aspnet/EntityFrameworkCore/files/3510065/EFCoreTest.zip)
Stack trace:
at Microsoft.EntityFrameworkCore.Query.RelationalQueryableMethodTranslatingExpressionVisitor.TranslateWhere(ShapedQueryExpression source, LambdaExpression predicate)
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.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.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 System.Linq.Queryable.Count[TSource](IQueryable`1 source)
at EFCoreTest.Data.OrdersRepository.Count(String value) in C:\source\repos\EFCoreTest\EFCoreTest\Data\OrdersRepository.cs:line 39
Steps to reproduce
Run the attached project. It includes the Northwind sample database in the Database folder.
EF Core version: EF Core 3.0 Preview 8
Database Provider: Microsoft.EntityFrameworkCore.SqlServer
Operating system: Windows 10 Pro 1903
IDE: Visual Studio 2019 v. 16.3.0 Preview 2.0
the issue that you refer is not the same. The other one is about how boolean functions are converted to SQL depending on the database provider.
This one is about a code throwing an exception.
As I explain before, this code was working as expected ith EF Core 2.2 and EF Core 3.0 Preview 5. And now it throws an exception when using EF Core 3.0 Preview 8.
I've attached an example of the code throwing the exception.
The issue linked is talking about translating ToString function on Boolean column. Earlier we translated it to server but it was incorrect translation. See #14205 (comment)
Hence we decided to block the translation in short term. In future we would add translation to server which is being tracked by #14205
Incorrect results can cause potential data corruption in database hence, those are higher priority to fix than exception.
This query thows an exception when materialized:
var records = Context.Set().Where(x => x.Customer.IsVip.ToString().Contains(value));
where IsVip is a boolean field.
It happens when using EF Core 3.0 Preview 8. But it worked until EF Core 3.0 Preview 5.
Steps to reproduce
Run the attached project. It includes the Northwind sample database in the Database folder.
Further technical details
EF Core version: EF Core 3.0 Preview 8
Database Provider: Microsoft.EntityFrameworkCore.SqlServer
Operating system: Windows 10 Pro 1903
IDE: Visual Studio 2019 v. 16.3.0 Preview 2.0
EFCoreTest.zip
The text was updated successfully, but these errors were encountered: