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

Enum types #33

Open
KillTrot opened this issue Oct 18, 2022 · 2 comments
Open

Enum types #33

KillTrot opened this issue Oct 18, 2022 · 2 comments

Comments

@KillTrot
Copy link

Hello,

thank you for this great writeup on dev.to.

Could you maybe extend the sample of how to use it with enums?

I have a client which I cannot change which makes request like $filter=Type+eq+'0'
where '0' is the int representation of the enum.

Is this possible?

@berviantoleo
Copy link
Member

berviantoleo commented Oct 18, 2022

I have a client which I cannot change which makes request like $filter=Type+eq+'0'
where '0' is the int representation of the enum. Is this possible?

I think currently OData supports filtering by the "string" representation. Example: https://localhost:8001/v1/Notes?$filter=Type eq 'Public'

Type

My enum:

public enum NotesType
{
    Public,
    Private
}

Maybe, do you mean this enum?

https://devblogs.microsoft.com/odata/tutorial-sample-use-enumeration-types-in-odata/


I think this issue will answer your doubt.

@KillTrot
Copy link
Author

Thank you for the quick response.

Unfortunately, it is not possible to change our client-applications to use the "string"-representation of the enum.

The last link you mentioned contains a NuGet package which unfortunately is not open source and throws an exception with dotnet 6.

I have read about the StringAsEnumResolver, but I don't get it to work correctly as I don't fully understand how to inject it into the OData services without using a edm model.
(For that there is actually a pending pull request, which is not merged yet)

Maybe you have an idea?

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

No branches or pull requests

2 participants