The binary operator Equal is not defined for the types 'System.Nullable`1[System.Boolean]' and 'System.Boolean' error for queries with complex predicates involving nullable boolean properties
See original GitHub issueI’ve updated EF from ver 1.0.1 to ver 1.1.0 and after runnig below query I got error.
var data = await _context.CustomerServices
.Include(a => a.ServiceEquipment)
.Include(a => a.ServiceAddresses)
.ThenInclude(a => a.Address)
.SingleOrDefaultAsync(a => a.Id == serviceId && !a.IsDeleted && !a.ServiceEquipment.IsDeleted);
the binary operator Equal is not defined for the types ‘System.Nullable`1[System.Boolean]’ and ‘System.Boolean’.
at System.Linq.Expressions.Expression.GetEqualityComparisonOperator(ExpressionType binaryType, String opName, Expression left, Expression right, Boolean liftToNull) at System.Linq.Expressions.Expression.Equal(Expression left, Expression right, Boolean liftToNull, MethodInfo method) at Microsoft.EntityFrameworkCore.Query.Sql.DefaultQuerySqlGenerator.SearchConditionTranslatingVisitor.VisitUnary(UnaryExpression expression) at Microsoft.EntityFrameworkCore.Query.Sql.DefaultQuerySqlGenerator.SearchConditionTranslatingVisitor.VisitBinary(BinaryExpression expression) at Microsoft.EntityFrameworkCore.Query.Sql.DefaultQuerySqlGenerator.SearchConditionTranslatingVisitor.VisitUnary(UnaryExpression expression) at Microsoft.EntityFrameworkCore.Query.Sql.DefaultQuerySqlGenerator.ApplyOptimizations(Expression expression, Boolean searchCondition, Boolean joinCondition) at Microsoft.EntityFrameworkCore.Query.Sql.DefaultQuerySqlGenerator.VisitSelect(SelectExpression selectExpression) at Remotion.Linq.Parsing.ThrowingExpressionVisitor.Visit(Expression expression) at Microsoft.EntityFrameworkCore.Query.Sql.DefaultQuerySqlGenerator.GenerateSql(IReadOnlyDictionary
2 parameterValues) at Microsoft.EntityFrameworkCore.Query.Internal.ShaperCommandContext.GetRelationalCommand(IReadOnlyDictionary
2 parameters) at Microsoft.EntityFrameworkCore.Query.Internal.AsyncQueryingEnumerable.AsyncEnumerator.<BufferlessMoveNext>d__9.MoveNext() — End of stack trace from previous location where exception was thrown — at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.EntityFrameworkCore.Storage.Internal.SqlServerExecutionStrategy.<ExecuteAsync>d__6`2.MoveNext()
when I remove !a.ServiceEquipment.IsDeleted
from query it works.
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (6 by maintainers)
FYI, for anyone else waiting for this to be released, you can get around it with a good ol’ fashioned hack:
Verified that this is fixed in the 1.1.1 candidate build.