question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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 issue

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.<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:closed
  • Created 7 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
bjcullcommented, Feb 5, 2017

FYI, for anyone else waiting for this to be released, you can get around it with a good ol’ fashioned hack:

a.ServiceEquipment.IsDeleted == (bool?)false
0reactions
analogrelaycommented, Feb 23, 2017

Verified that this is fixed in the 1.1.1 candidate build.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting error : The binary operator Equal is not defined for ...
Here are the steps: Get type converter for property type. Check whether it can convert string to property type.
Read more >
Linq to RQL: The binary operator Equal is not defined for ...
Linq to RQL: The binary operator Equal is not defined for the types 'System.Nullable. Relates to 1. Relates to 1 issue (0 unresolved)....
Read more >
The binary operator Equal is not defined for the types ' ...
My Sales Order data entry application runs fine in my development environment. The sales order screen has a lines list view.
Read more >
Working with Expression Trees in C# • Oleksii Holub
However, if we try to run this, we will get an error: The binary operator Add is not defined for the types 'System.String'...
Read more >
OData Version 4.01. Part 2: URL Conventions - Index of /
This document defines rules for URLs for data and metadata exposed by an ... that is part of a Boolean expression, the type...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found