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

Serialize/Deserialize for readonly properties

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Fixed
    • Affects Version/s: 1.4
    • Fix Version/s: 1.4.1
    • Component/s: Feature Request
    • Labels:
    • Environment:
      All
    • Backwards Compatibility:
      Fully Compatible

      Description

      Sometimes we have some readonly properties, but they should be persisted to db, mainly for index and search purpose.

      These properties's values are generated from other properties, but is criticaly useful when perform a search in db, so they should be readonly and should be serialized to BSON.

      My suggest is that the C# driver by default serialize all read/write properties (same as current), but give a configure possibility to serialize readonly properties, such as:

      map.MapProperty(c => c.ReadOnlyProperty);

      Then once a value is deserialized from BSON, and corresonding property doesn't have a set accessor, C# driver does not throw an exception, this causes a modification to /Bson/Serialization/BsonMemberMap.cs (line 560 as in master on github).

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: