Dapper icon indicating copy to clipboard operation
Dapper copied to clipboard

Add option to persist enum names

Open bfriesen opened this issue 2 years ago • 3 comments

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.

bfriesen avatar Mar 20 '22 03:03 bfriesen

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

joostmeijles avatar Apr 20 '22 13:04 joostmeijles

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 😂

nyan-cat avatar Dec 28 '22 12:12 nyan-cat

Will this ever be in a release?

SeppPenner avatar Jun 02 '23 07:06 SeppPenner