Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-415

BsonDocument.ToDictionary converts an array of nested documents/arrays to an array of null values

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

      If a BsonDocument contains an array of nested documents or nested arrays, calling BsonDocument.ToDictionary will convert all of the array values to null. It looks like this occurs because BsonArray.CopyTo calls each of its elements' RawValue methods, which return null for BsonDocument and BsonArray instances. I've attached a CS file with new ToDictionary and helper methods that fix this error. At the bottom of the file is the test case I used to reproduce and then correct it.

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            dhgoldman Daniel Goldman
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: