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

Wrong value in odata query when using nullable enum #105

Open
casually-creative opened this issue Oct 14, 2022 · 1 comment
Open

Wrong value in odata query when using nullable enum #105

casually-creative opened this issue Oct 14, 2022 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@casually-creative
Copy link

casually-creative commented Oct 14, 2022

Let's say you have an enum called Status and an entity with 2 properties. One property is of type Status, and the other is of type nullable Status.

public enum Status
{
    Active   = 0,
    Inactive = 1
}

public class SomeEntity
{
    public Status StatusOne { get; set; }
    public Status? StatusTwo { get; set; }
}

Imagine we now create a query with a filter on these properties like so:

string oDataQuery = new ODataQueryBuilder()
    .For<SomeEntity>("some_entity")
    .ByList()
    .Filter(e =>
        e.StatusOne == Status.Active &&
        e.StatusTwo == Status.Active
    )
    .ToUri()
    .ToString();

The resulting query now contains the proper underlying int value of 0 for StatusOne, while it contains the name of the enum field "Active" for property two:

some_entity?$filter=StatusOne eq 0 and StatusTwo eq 'Active'

I would expect both cases would use the underlying int value. Would love to see a fix for this.

@ZEXSM ZEXSM self-assigned this Oct 14, 2022
@ZEXSM ZEXSM added the bug Something isn't working label Oct 14, 2022
@casually-creative
Copy link
Author

Hello @ZEXSM, is this issue getting a fix soon? It's been over a year. Sad to see this repo isn't being maintained anymore :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants