0
我在MongoDB C#中查询以下内容时遇到问题。我在mongo客户端的代码是如何在MongoDB C#驱动中使用“Or”语句?
db.collection.find({ $or: [ { quantity: { $lt: 20 } }, { price: 10 } ,{price:100},{name:"x"}] })
但是如何在C#中查询相同的内容。 我能够查询以下蒙戈客户端代码语句
db.collection.find({type:"food"},{name:1,quantity:1})
为
var match = new BsonDocument() { { "$match", new BsonDocument { {"type":"food" } } } };
var project = new BsonDocument(){ { "$project", new BsonDocument{ { "name", 1 } { "quantity", 1 } } } };
AggregateArgs AggregationPipeline = new AggregateArgs() { Pipeline = new[] { match, project } };
var aggregate = Collection.Aggregate(AggregationPipeline);
我使用蒙戈升C驱动器1.9.2。 谢谢。
嗨@Mahdi,我使用MongoCSharpDriver。 1.9.2。此版本中不存在构建器上下文。谢谢 – coder