Is there a way to save Enums as string names rather than ordinal values?
Example:
Imagine I have this listing:
public enum Gender { Female, Male }
Now, if some imaginary user exists with
... Gender gender = Gender.Male; ...
it will be stored in the MongoDb database as {... "Gender": 1 ...}
but I would prefer something like this {... "Paul": "Man" ...}
Is it possible? Custom mapping, reflection tricks, whatever.
My context: I use strongly typed collections over POCO (well, I mark AR and sometimes use polymorphism). I have a subtle level of data access abstraction in the Unit Of Work form. Therefore, I do not serialize / deserialize each object, but I can (and do) define some ClassMaps. I am using the official MongoDb + flu-mongodb driver.
c # mongodb mongodb-.net-driver
Kostassoid Aug 09 2018-11-12T00: 00Z
source share