Click here to Skip to main content
15,883,922 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am saving a field value as DatetimeOffset in Mongodb via C# driver which is being saved in the db as

"createdAt" : [
           NumberLong(637166528776997165),
           NumberInt(0)
       ]


But when trying to get it back its not getting parsed/mapped.

When looked upon using result.ToJson() found out that its coming as
"createdAt" : [NumberLong(0), 0]
.

What I have tried:

Already tried

var serializer = new DateTimeSerializer(DateTimeKind.Utc, BsonType.Document);
          BsonSerializer.RegisterSerializer(typeof(DateTime), serializer);

          var sr = new DateTimeOffsetSerializer();
          BsonSerializer.RegisterSerializer(typeof(DateTimeOffset), sr);
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900