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

Query: The binary operator Equal is not defined for the types 'System.Nullable`1[System.Boolean]' and 'System.Boolean'. #8065

Closed
twenzel opened this issue Apr 4, 2017 · 1 comment
Assignees
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Milestone

Comments

@twenzel
Copy link
Contributor

twenzel commented Apr 4, 2017

This error will be produced by the weird OData filter query and can be reproduced using following query:

 _db.Assets.Where(a => ((a.SerialNumber == null || false) ? null : (bool?)a.SerialNumber.Contains("123")) == true)

My entity looks like:

public class Asset
    {     
        public int Id { get; set; }
  
        public string SerialNumber { get; set; }
    }

The OData controller:

public class AssetsController : System.Web.OData.ODataController
    {
        private readonly DataContext _db;

        public AssetsController(DataContext db)
        {
            _db = db;
        }

        [EnableQuery]
        public IQueryable<Asset> Get()
        {                       
            return _db.Assets;
        }     
    }

The OData query request looks like:

http://localhost:52001/odata/Assets?$filter=contains(SerialNumber,'30Q')

I'm using EFCore 1.1.1.

@maumar
Copy link
Contributor

maumar commented Apr 6, 2017

Verified that this is fixed in current bits. As a temporary workaround you can try disabling null propagation in OData:

Modify ODataController’s EnableQueryAttribute, by including:
HandleNullPropagation = HandleNullPropagationOption.False

@maumar maumar closed this as completed Apr 6, 2017
@maumar maumar added type-bug closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. and removed type-investigation labels Apr 6, 2017
@ajcvickers ajcvickers changed the title The binary operator Equal is not defined for the types 'System.Nullable`1[System.Boolean]' and 'System.Boolean'. Query: The binary operator Equal is not defined for the types 'System.Nullable`1[System.Boolean]' and 'System.Boolean'. May 9, 2017
@divega divega added closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. and removed closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. labels May 10, 2017
@ajcvickers ajcvickers modified the milestones: 2.0.0-preview1, 2.0.0 Oct 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Projects
None yet
Development

No branches or pull requests

4 participants