Id property mapping issues when using camel-case convention and mapping-by-code approach

XMLWordPrintableJSON

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

      I'm experiencing a strange issue where the driver is correctly mapping some class properties excepting the SomeClass.Id property when using CamelCaseElementNameConvention.

      The code is something like the following one:

                     var pack = new ConventionPack();
                                     pack.Add(new CamelCaseElementNameConvention());
      
                                     ConventionRegistry.Register(
                                       "SimsaConventions",
                                       pack, t => true);
      

      I've tried to add a BsonClassMap using m.AutoMap() and then trying to map the id property and setting an element name "id" to force it to work with no luck, while adding [BsonElement("id")] in the Id property workarounds the issue.

      BTW, I understand that the camel-case convention should be used during serialization and deserialization and it shouldn't produce a conflict.

      The exception thrown during serialization without using BsonElementAttribute is that "id" element name can't be found.

      Using Visual Studio's debugger watches I could find that member name is "Id" even after call .SetElementName("id"). BTW, I insist in that I understand that both camel-case convention and auto-mapping should work together. Am I wrong?

            Assignee:
            Unassigned
            Reporter:
            Matías Fidemraizer
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: