Details
-
New Feature
-
Resolution: Duplicate
-
Major - P3
-
None
-
2.7.0
-
None
-
Windows 10, 64-bit architecture, .NetFramework 471
Description
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.
Attachments
Issue Links
- duplicates
-
CSHARP-2096 Make EnumRepresentationConvention also affect collections of Enums
-
- Backlog
-