[CSHARP-2972] IgnoreIfDefault not working? Created: 19/Feb/20 Updated: 30/Mar/20 Resolved: 30/Mar/20 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | BSON |
| Affects Version/s: | 2.10.2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Brecht Vanhaesebrouck | Assignee: | Robert Stam |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Windows 10 |
||
| Description |
|
Setting IgnoreIfDefault to true through the BsonClassMap.RegisterClassMap call does not seem to work. Eg:
TriesDone gets serialized to the database with a default value of 0. I am having the same issue with reference types set to null. |
| Comments |
| Comment by Robert Stam [ 10/Mar/20 ] | ||||||||||||||||||||||||||||||||||||||||||||
|
I am unable to reproduce this. I couldn't use all of your code because it references types that weren't provided. But since your initial description mentioned the TriesDone property I simplified the example to:
Note that serialized form (in JSON here) does NOT contain the TriesDone field.
| ||||||||||||||||||||||||||||||||||||||||||||
| Comment by Brecht Vanhaesebrouck [ 20/Feb/20 ] | ||||||||||||||||||||||||||||||||||||||||||||
|
Here's the full class map:
This is the model itself:
| ||||||||||||||||||||||||||||||||||||||||||||
| Comment by Dmitry Lukyanov (Inactive) [ 19/Feb/20 ] | ||||||||||||||||||||||||||||||||||||||||||||
|
Hello brecht.vanhaesebrouck@sea-invest.com, can you please provide more full repro. In particular the full class description. |