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

Add option to persist enum names #1762

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

bfriesen
Copy link

When the new PersistEnumsByName setting is true, an enum is persisted by its name (Enum.ToString()) instead of by its numeric value.

This is sort of an alternative solution to issue #259, but it doesn't directly address that issue by changing how custom type handlers are used. Instead, it adds a new setting, PersistEnumsByName, which I believe addresses what most users actually want - to be able to persist an enums by their name. When this setting is false (its default value), the current behavior is completely unchanged. Admittedly, there is no granularity with how enums are handled; you couldn't have some enums persisted by name and others by their underlying value. Supporting that scenario would add significant complexity, and I don't think there is enough demand to justify it.

Fixes #813.

When the new `PersistEnumsByName` setting is true, an enum is persisted
by its name (`Enum.ToString()`) instead of by its underlying numeric
value.
@bfriesen bfriesen marked this pull request as ready for review March 20, 2022 03:36
@joostmeijles
Copy link

Nice improvement! Is there an ETA for this to get into a release?

@nyan-cat
Copy link

Nice improvement! Is there an ETA for this to get into a release?

Hello from 2023 eve. There are a bunch of same Dapper enum issues opened for 8 years, and nobody gives a damn about it. I'm thinking of forking the library, merging commits above into it, and publish to NuGet so everybody could finally use a mature version of this ORM 😂

@SeppPenner
Copy link

Will this ever be in a release?

Thanks, SeppPenner!
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

Successfully merging this pull request may close these issues.

Store Enum Value as String
4 participants