[CSHARP-441] Serialize/Deserialize for readonly properties Created: 13/Apr/12 Updated: 02/Apr/15 Resolved: 13/Apr/12 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | Feature Request |
| Affects Version/s: | 1.4 |
| Fix Version/s: | 1.4.1 |
| Type: | Improvement | Priority: | Minor - P4 |
| Reporter: | Gray Zhang | Assignee: | Craig Wilson |
| Resolution: | Done | Votes: | 0 |
| Labels: | serialization | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| 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). |
| Comments |
| Comment by Craig Wilson [ 13/Apr/12 ] |
|
This has been implemented and merged to master. |