MongoDB C# driver enum mapping

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      I have Enum:

      {{}}

      public enum SomeType
      {
         TypeA,
         TypeB, 
         TypeC
      }

      {{}}

      but in MongoDB i would like this map to: type_a type_b type_c

      I'm using EnumRepresentationConvention(BsonType.String)

      I tried:

      {{}}

      public enum SomeType
      {
         [BsonElement("type_a")]
         TypeA,
         [BsonElement("type_b")]
         TypeB, 
         [BsonElement("type_c")]
         TypeC
      }

      {{}}

      but this doesn't work. Im getting exception:

      Requested value 'type_a' was not found.

      Is anyone know how can achieve such mapping in MongoDb C# driver?

              Assignee:
              Wan Bachtiar
              Reporter:
              Jakub Dropia
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: