[CSHARP-1452] BsonDocument which is null actually create an object with one name-value pair Created: 18/Oct/15 Updated: 03/Dec/20 Resolved: 03/Dec/20 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | Serialization |
| Affects Version/s: | 2.1 |
| Fix Version/s: | None |
| Type: | Task | Priority: | Major - P3 |
| Reporter: | Itzhak Kagan | Assignee: | Unassigned |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | question | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
windows 7 64 bit WiredTiger engine |
||
| Issue Links: |
|
||||||||
| Description |
|
If I create a property in a class like:
If the UserSettings is null when a new document is inserted then the driver actually creates a bson document with one name-value pair like that:
That looks strange to me since i expected that property to be null like that:
Am I missing something? Thanks, |
| Comments |
| Comment by Itzhak Kagan [ 19/Oct/15 ] | ||||||||||
|
Thanks Robert, I read the Thanks, | ||||||||||
| Comment by Robert Stam [ 18/Oct/15 ] | ||||||||||
|
I understand that this would look strange to you. I encourage you to read the description and comments on the The problem traces back to how to represent the difference between a BsonValue whose value is a BSON null vs a BsonValue whose value is is C# null. The difference is illustrated here:
These two different representations are necessary in order to successfully round trip the two different values. While this example is using BsonValue as the type for V, the decision was made to treat all subclasses of BsonValue (including BsonDocument) the same way. |