[CSHARP-395] IDictionary support for extra elements serialization Created: 17/Feb/12 Updated: 02/Apr/15 Resolved: 16/Mar/12 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | None |
| Affects Version/s: | 1.3.1 |
| Fix Version/s: | 1.4 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Manuel Warum | Assignee: | Robert Stam |
| Resolution: | Done | Votes: | 0 |
| Labels: | driver, serialization | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
Hi, I am requesting a slight improvement in behaviour concerning extra elements in typed class maps. Currently the driver expects the property in which extra elements are stored to be of the BsonDocument type. However, this may not always be possible or reasonable. It also requires coupling between the project containing the model classes and MongoDB. In essence, I ask to remove this need to reference the MongoDB driver due from the model space. I think the safest way to go about this without breaking compability is to allow the extra elements container to be a IDictionary, ICollection of key-value pairs, or something along those lines. |
| Comments |
| Comment by Robert Stam [ 16/Mar/12 ] |
|
The extra elements property or field can now be of type IDictionary<string, object> (or any type implementing this interface) as an alternative to BsonDocument, which is still supported. When using IDictionary<string, object> BSON values are mapped to equivalent .NET values when possible. BSON arrays map to List<object> (not object[], so that you can add or remove values) and nested BSON documents map to nested IDictionary<string, object> instances. |