-
Type: Improvement
-
Resolution: Done
-
Priority: Minor - P4
-
Affects Version/s: 1.4
-
Component/s: Feature Request
-
Environment:All
-
Fully Compatible
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).