【发布时间】:2019-04-24 20:44:10
【问题描述】:
我有一个简单的类来表示 MongoDB 文档中的字段
class Measurement
{
public ObjectId id { get; set; }
public int s { get; set; }
public int[] p { get; set; }
public int dt { get; set; }
public int ml { get; set; }
}
我正在尝试使用
获取符合我的条件的文档var collection = database.GetCollection<Measurement>(mongoCollectionName);
var query = from a in collection.AsQueryable<Measurement>()
where a.dt > 100
select a;
当条件被删除时,我确实收到了所有文件,但没有条件。响应说没有匹配的文件,但有(例如 dt=1538555)
查询看起来像这样 {aggregate([{ "$match" : { "dt" : { "$gt" : 100 } } }])}。 我使用来自这个线程和 mongodb 文档的响应来构建我的示例 MongoDB C# Aggregation with LINQ
如果能解决我可能犯的愚蠢错误,我将不胜感激
【问题讨论】: