[CSHARP-511] Ability To Apply [BsonDateTimeOptions(Kind = DateTimeKind.Local)] To All DateTimes Created: 25/Jun/12 Updated: 19/Oct/16 Resolved: 25/Jun/12 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Major - P3 |
| Reporter: | Ryan Hoffman | Assignee: | Craig Wilson |
| Resolution: | Done | Votes: | 3 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
It would be great to have a global setting (like the ID generator setting) to apply [BsonDateTimeOptions(Kind = DateTimeKind.Local)] to all DateTime objects persisted. |
| Comments |
| Comment by Ryan Hoffman [ 25/Jun/12 ] |
|
Actually it looks like on the linked page there is a comment by @Robert Stam saying: "You change the value of the static property called DateTimeSerializationOptions.Defaults." So you can do this: Thanks for the link! |
| Comment by Craig Wilson [ 25/Jun/12 ] |
|
There is an ISerializationOptionsConvention you can implement. You can check to see if the memberInfo's type is a DateTime and return DateTimeSerializationOptions. Have a look http://www.mongodb.org/display/DOCS/CSharp+Driver+Serialization+Tutorial for how to create a profile and apply it. |