[CSHARP-2993] BsonIgnoreIfEmpty property attribute Created: 03/Mar/20 Updated: 31/Mar/22 |
|
| Status: | Backlog |
| Project: | C# Driver |
| Component/s: | BSON |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Major - P3 |
| Reporter: | Tim Arheit | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
C# |
||
| Description |
|
The driver supports BsonIgnoreIfNull and BsonIgnoreIfDefault which of course simply skip serializing properties based on their value. For Collection properties (List, hashset, dictionary, etc.) it would be great to have a [BsonIgnoreIfEmpty] property that would skip serialization on both null or if the collection was empty. |
| Comments |
| Comment by Tim Arheit [ 03/Mar/20 ] |
|
Of course I realize this can be done with the ShouldSerializeXyz method, but it is a common thing at least for our use. |