在一个集合中,我将IsoDates存储如下:
SubmitDateTime" : ISODate("2015-03-02T07:39:05.463Z")
现在我想使用以下属性将此属性映射到MyModel
:
public class MyModel
{
public DateTime SubmitDateTime { get; set; }
}
然后将其映射如下:
GetCollection<MyModel>("collection_name").Find(myQuery).ToListAsync();
不幸的是我收到了这个错误:
System.ArgumentOutOfRangeException
BsonDateTime MillisecondsSinceEpoch的值-9223372036854775808超出了可以转换为.NET DateTime的范围
有谁知道如何解决这个问题?
感谢。
PS我最初使用Mongo shell中的这个脚本将此格式“2015-03-30T10:50:01.813”的字符串表示转换为IsoDate
:
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)}})
}
也许可以在那里取得进步。