Mongo DBDriver, how to serialise DateTimeOffset
Hi guys,
I just learned that mongo stores datetime offsets as an array, and that I can use BsonRepresentation(BsonType.String)] to save them as string instead.
Is there a way that I can specify the a custom bson representation fluently, instead of having to decorate each DatetTimeOffset property in my classes?
1 Reply
Answering if myself:
BsonSerializer.RegisterSerializer(new DateTimeOffsetSerializer(BsonType.Document));
After your have registered your MongoClient