-
Type: New Feature
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: 2.7.0
-
Component/s: Serialization
-
None
-
Environment:Windows 10, 64-bit architecture, .NetFramework 471
Create a serialization convention like so:
ConventionRegistry.Register("EnumStringConvention", new ConventionPack { new EnumRepresentationConvention(BsonType.String) }, t => true);
Then define an enum like so:
[PublicAPI] public enum JobCategory { Remodel, Repair }
Finally add a list of enums to your data model
public class JobModel { public List<JobCategory> JobCategories { get; set; } = new List<JobCategory>(); }
Write to mongodb then inspect the bson doc and notice that `JobCategory` is a list of int32 and not a list of strings.
- duplicates
-
CSHARP-2096 Make EnumRepresentationConvention also affect collections of Enums
- In Code Review