C
C#3y ago
darker5914

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
darker5914
darker5914OP3y ago
Answering if myself: BsonSerializer.RegisterSerializer(new DateTimeOffsetSerializer(BsonType.Document)); After your have registered your MongoClient
Want results from more Discord servers?
Add your server