问题
In a collection I have IsoDates stored as follows:
SubmitDateTime" : ISODate("2015-03-02T07:39:05.463Z")
Now I want to map this property to MyModel
with the following property:
public class MyModel
{
public DateTime SubmitDateTime { get; set; }
}
And then map it as follows:
GetCollection<MyModel>("collection_name").Find(myQuery).ToListAsync();
Unfortunately I get this error:
System.ArgumentOutOfRangeException
The value -9223372036854775808 for the BsonDateTime MillisecondsSinceEpoch is outside therange that can be converted to a .NET DateTime
Does anyone know how to fix this?
Thanks.
PS I originally converted string representations of this format "2015-03-30T10:50:01.813" to the IsoDate
with this script in the Mongo shell:
var cursor = db.collection_name.find()
while (cursor.hasNext()) {
var doc = cursor.next();
db.collection_name.update({_id : doc._id}, {$set : {SubmitDateTime : new Date(doc.SubmitDateTime)}})
}
Perhaps an improvement can be made there.
来源:https://stackoverflow.com/questions/31627240/how-to-convert-isodate-to-datetime