I was using this line to set the datetime defaults.
DateTimeSerializationOptions.Defaults = DateTimeSerializationOptions.LocalInstance;
I get this warning. 'MongoDB.Bson.Serialization.Options.DateTimeSerializationOptions.Defaults' is obsolete: 'Create and register a DateTimeSerializer with the desired options instead.'
But i couldn't find an example to change it... how can I change this obsolute usage?
Register the date/time serializer like this:
BsonSerializer.RegisterSerializer(typeof(DateTime), DateTimeSerializer.LocalInstance);
Note that you can't register a serializer once one has already been registered. Also, the driver creates a default serializer for each type the first time it needs one. So you need to call this code before you make your first call to the driver to read or write data.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With