I'm trying to save an enum value as lowercase or with my custom representation on MongoDB using the C# driver. I already figured out how to save the enum value as string on the database, doing something like this
class MyClass
{
...
[BsonRepresentation(representation: BsonType.String)]
public MyEnum EnumValue { get; set; }
...
}
and the enum class is like this
[JsonConverter(converterType: typeof(StringEnumConverter))]
enum MyEnum
{
[EnumMember(Value = "first_value")]
FirstValue,
[EnumMember(Value = "second_value")]
SecondValue
}
But on MongoDB the enum value is stored as it is in the enum class (not like what is specified in the EnumMember attribute). How can I tell MongoDB to store the enum value lowercase or with the EnumMember value?