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

Add indexing to BsonValue

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • 1.8
    • 1.6
    • None
    • None

    Description

      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.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: