[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.

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