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

An exception is thrown when Enum values are compared #499

Closed
ilyapavlovdx opened this issue Feb 9, 2022 · 1 comment · Fixed by #563
Closed

An exception is thrown when Enum values are compared #499

ilyapavlovdx opened this issue Feb 9, 2022 · 1 comment · Fixed by #563
Assignees
Labels

Comments

@ilyapavlovdx
Copy link

An exception with the following message is thrown when Enum values are compared by "<" or ">":

System.InvalidOperationException: The LINQ expression 'DbSet()
.Where(n => n.Status.CompareTo((object)Read) < 0)' could not be translated.

The issue is reproduced in EF Core v5.06

Filter:

[[["status","<",1],"or",["status","=",null]],"or",[["status","=",1],"and",[[["id","<",99],"or",["id","=",null]],"or",[["id","=",99],"and",["id","<",99]]]]]

Data model:

public class Note
    {
        public int Id { get; set; }
        public string Text { get; set; }
        public Status Status { get; set; }
    }
    public enum Status
    {
        Unread = 0,
        Read = 1,
    }
@AlekseyMartynov AlekseyMartynov self-assigned this Feb 9, 2022
@AlekseyMartynov
Copy link
Contributor

Thanks @ilyapavlovdx

Possibly related: #493 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants