【问题标题】:How can I fix a matching error with dates in C# MOngoDB如何修复 C# MOngoDB 中的日期匹配错误
【发布时间】:2020-08-06 02:02:26
【问题描述】:

我正在尝试将 Status 对象与 Active 标志(true 或 false)和 Status 日期匹配。

我正在执行下面的代码,如果我只保留活动部分它可以工作,但是当我添加数据部分时它返回空。 Data 是 C# 中的 DateTime 字段。

    var aggregate = orders.Aggregate().Match(new BsonDocument
                {
                    {"Status.Active", new BsonDocument("$eq", isActive)},
                    {"Status.Data", new BsonDocument
                        { 
                            {"$gte", begin },
                            {"$lte", end }
                        }
                    }
                })

【问题讨论】:

  • 你能显示数据和begin/end变量吗?

标签: c# mongodb aggregation


【解决方案1】:

已修复,但有一个解决方法...我将“DATA”属性类型更改为 int 而不是 DateTime,并且它起作用了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-12-05
    • 2021-10-21
    • 2019-10-09
    • 2019-01-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多