Skip to content

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 #7061

Closed
@mo-esmp

Description

I'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(IReadOnlyDictionary2 parameterValues) at Microsoft.EntityFrameworkCore.Query.Internal.ShaperCommandContext.GetRelationalCommand(IReadOnlyDictionary2 parameters)
at Microsoft.EntityFrameworkCore.Query.Internal.AsyncQueryingEnumerable.AsyncEnumerator.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.d__6`2.MoveNext()

when I remove !a.ServiceEquipment.IsDeleted from query it works.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

closed-fixedThe issue has been fixed and is/will be included in the release indicated by the issue milestone.type-bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions