代码是自我解释的。当我从DB检索对象时,DateTime
与我插入的对象不同。我想知道如何解决它。
class MyClass
{
public ObjectId _id;
public DateTime date;
}
MongoClient client = new MongoClient("mongodb://localhost");
MongoServer server = client.GetServer();
MyClass tmp = new MyClass();
tmp.date = DateTime.Now;
Console.WriteLine(tmp.date); // 11.7. 21:38:18
var coll = server.GetDatabase("test").GetCollection("test");
coll.Insert(tmp);
tmp = server.GetDatabase("test").GetCollection<MyClass>("test").FindOne();
Console.WriteLine(tmp.date); // 11.7. 19:34:46