Details
-
Improvement
-
Resolution: Done
-
Major - P3
-
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
Issue Links
- is related to
-
CSHARP-558 Replace AsXyz and ToXyz in BsonValue with GetXyz in BsonDocument
-
- Closed
-
-
CSHARP-560 Remove explicit conversions from BsonValue
-
- Closed
-