Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-211

BsonClassSerializer should look for ShouldSerializeXyz methods and use them

    XMLWordPrintableJSON

Details

    • Icon: New Feature New Feature
    • Resolution: Done
    • Icon: Minor - P4 Minor - P4
    • 1.1
    • 1.0
    • Feature Request
    • None

    Description

      These methods would allow the decision whether a particular property should be serialized to be made at runtime. This is similar to [BsonIgnoreIfNull] but allows the developer to use custom criteria to decide whether to serialize the property or not. For example:

      public class Employee {
      // other fields
      public string Zip;

      public bool ShouldSerializeZip(string value)

      { return value != null && value != "' && value != "00000"; }

      }

      Attachments

        Activity

          People

            robert@mongodb.com Robert Stam
            robert@mongodb.com Robert Stam
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: