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

Support for multiple enums (flags) in EnumToStringConverter #20994

Closed
risogolo opened this issue May 20, 2020 · 7 comments
Closed

Support for multiple enums (flags) in EnumToStringConverter #20994

risogolo opened this issue May 20, 2020 · 7 comments

Comments

@risogolo
Copy link

risogolo commented May 20, 2020

Seems like EnumToStringConverter / StringEnumConverter does not support enums with multiple combined options
InProgress = 1,
NotCancelled = 7,
State = InProgress | NotCancelled

any plans to support that?

@roji
Copy link
Member

roji commented May 20, 2020

@risogolo this would require something like concatenating the different values in a comma-separated string, after discovering which exact values are set, which isn't trivial to do. I'm not sure it's a good idea for EF Core to do this out of the box.

@ajcvickers we may want to detect [Flags] enums and emit an informative error, at least unless we decide to properly handle them.

@ajcvickers
Copy link
Contributor

@roji Duplicate of #20094. My understanding is that the string will be a numeric value if it represents multiple states, but will still round-trip correctly.

@roji
Copy link
Member

roji commented May 20, 2020

Duplicate of #20094

@roji roji marked this as a duplicate of #20094 May 20, 2020
@roji roji closed this as completed May 20, 2020
@roji
Copy link
Member

roji commented May 20, 2020

Thanks...

My understanding is that the string will be a numeric value if it represents multiple states, but will still round-trip correctly.

I'm not sure what value there is in storing a number in a string column (why not just store it in an int column), but yeah, it would work.

@risogolo
Copy link
Author

Guys we are talking about EnumToStringConverter, I need to see string representation of enum in DB, so I guess numeric value does not make sence.

@roji
Copy link
Member

roji commented May 21, 2020

@risogolo so what exact string representation are you looking for for InProgress | NotCancelled?

@risogolo
Copy link
Author

something visible, for example "InProgress; NotCancelled"

@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants