I have to serialize the following class with C# driver:
but I want to ignore sample2 field if this subdoc has no fields (if both dates are null).
For now I can use ShouldSerializesample2, but i would like to implement that with some attribute like [BsonIgnoreIfNoElements]. If json has complex structure with nested nullable elements in subdocs it will be best solution.
It's an open question how often this situation arises. Maybe this attribute deserves implementation. What's your opinion?