c# - 使用 C# 驱动程序从 mongo 集合中获取 DateTime

标签 c# mongodb

我有以下对象:

public class QueueItem
{
    public long _id { get; set; }
    public SiteMapRequestState State { get; set; }
    public int WorkerId { get; set; }
    public DateTime QueuedTime { get; set; }
    public DateTime StartWorkTime { get; set; }
}

当我将对象保存到 mongo 时,日期显示正确(DateTime 字段包含我插入的正确日期)。然而,当我拉动这个物体时,我得到了不同的时间(-3 小时)。

例如: 我使用 StartWorkTime = 6/26/2012 10:00:00 AM 保存对象,然后从集合中获取对象时 StartWorkTime 等于 6/26/2012 7:00:00上午。 这使得过程时间的计算错误。

我正在使用最新的 c# 驱动程序 (1.4.2.4500) 并在同一台机器上运行代码和 mongo 服务器。

什么会导致差异?

谢谢!

最佳答案

关于c# - 使用 C# 驱动程序从 mongo 集合中获取 DateTime,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11202753/

相关文章:

c# - NancyFX 中的静态内容与 ASP.Net Core

c# - 错误 : "The node to be inserted is from a different document context"

c# - httputility 在框架 3.5 的当前上下文中不存在

MongoDB 查找所有数组元素都等于某个值的文档

c# - 使用 Sleep 模拟 Thread Yield 方法

c# - 如何在不包括引用的解决方案中获取每个项目的程序集?

node.js - Mongoose更新文档: updates just the first one

node.js - 数据库不是使用 Mongoose 和 Node.js 创建的

node.js - 在两个 Node 应用程序之间共享 session

node.js - 构建 Node.js API(使用标准 MongoDB URI 的 mongodb 连接出现意外 token 错误)