[CSHARP-563] Add indexing to BsonValue Created: 09/Sep/12  Updated: 20/Mar/14  Resolved: 01/Dec/12

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: 1.6
Fix Version/s: 1.8

Type: Improvement Priority: Major - P3
Reporter: Robert Stam Assignee: Robert Stam
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to CSHARP-558 Replace AsXyz and ToXyz in BsonValue ... Closed
is related to CSHARP-560 Remove explicit conversions from Bson... Closed

 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.



 Comments   
Comment by auto [ 01/Dec/12 ]

Author:

{u'date': u'2012-09-09T03:58:38Z', u'email': u'robert@10gen.com', u'name': u'rstam'}

Message: CSHARP-563: modified the rest of the driver to take advantage of the new autoindex feature of BsonValue.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/1ce03da93d1f8dc22c89c84867e2d9c536be7ab9

Comment by auto [ 01/Dec/12 ]

Author:

{u'date': u'2012-09-09T03:48:29Z', u'email': u'robert@10gen.com', u'name': u'rstam'}

Message: CSHARP-563: throw NotSupportedException instead of InvalidOperationException and provide better error message when indexer is used on a BsonValue that doesn't support it.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/083beb871489f49b948ce1fe919aa8b413fad547

Comment by auto [ 01/Dec/12 ]

Author:

{u'date': u'2012-09-09T01:15:48Z', u'email': u'robert@10gen.com', u'name': u'rstam'}

Message: CSHARP-563: add autoindexing to BsonValue so you no longer have to downcast to BsonDocument or BsonArray to index.

Conflicts:
MongoDB.Bson/ObjectModel/BsonDocument.cs
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/85ad35957dc7d49254fa2fbaaf78cd14e1085eac

Comment by Robert Stam [ 29/Nov/12 ]

Reopened to backport feature to 1.8.

Comment by Robert Stam [ 10/Sep/12 ]

Pushed to x2.0.

Comment by auto [ 10/Sep/12 ]

Author:

{u'date': u'2012-09-08T20:58:38-07:00', u'email': u'robert@10gen.com', u'name': u'rstam'}

Message: CSHARP-563: modified the rest of the driver to take advantage of the new autoindex feature of BsonValue.
Branch: x2.0
https://github.com/mongodb/mongo-csharp-driver/commit/88c9c13a0108ef513feea7144e2d22279ff03deb

Comment by auto [ 10/Sep/12 ]

Author:

{u'date': u'2012-09-08T20:48:29-07:00', u'email': u'robert@10gen.com', u'name': u'rstam'}

Message: CSHARP-563: throw NotSupportedException instead of InvalidOperationException and provide better error message when indexer is used on a BsonValue that doesn't support it.
Branch: x2.0
https://github.com/mongodb/mongo-csharp-driver/commit/22945d265b4a3b878853251eb89214f6f437ec4d

Comment by auto [ 10/Sep/12 ]

Author:

{u'date': u'2012-09-08T18:15:48-07:00', u'email': u'robert@10gen.com', u'name': u'rstam'}

Message: CSHARP-563: add autoindexing to BsonValue so you no longer have to downcast to BsonDocument or BsonArray to index.
Branch: x2.0
https://github.com/mongodb/mongo-csharp-driver/commit/114ba5d6d30f720128a2530bb0d0c09aa847453d

Comment by Robert Stam [ 09/Sep/12 ]

In code review again.

Comment by Robert Stam [ 09/Sep/12 ]

The exception thrown when indexing is used on a BsonValue that doesn't support it should be a NotSupportedException, not an InvalidOperationException.

Comment by Robert Stam [ 09/Sep/12 ]

In code review.

Generated at Wed Feb 07 21:37:12 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.