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

Add indexing to BsonValue

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.8
    • Affects Version/s: 1.6
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Define indexing at the BsonValue level so that indexing is available automatically without having to downcast the BsonValue to a BsonDocument or BsonArray. If indexing is invoked on a BsonValue that is not a document or array an InvalidOperationException will be thrown.

      This allows code to be written much more concisely. For example:

      var streetAddress = document.AsBsonDocument["Addresses"].AsBsonArray[0].AsBsonDocument[0].AsString;
      

      can now be written simply as:

      var streetAddress = document["Addresses"][0][0].AsString;
      

      NOTE: this new feature is not really compatible with the proposal in CSHARP-558, but might be preferable to CSHARP-558.

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

              Created:
              Updated:
              Resolved: