c# Mongodb两个字段不相等 MongoDB原生查询

var document = new BsonDocument{
{ "$where","this.StarTime!=this.EndTime"},
{ "Closed",1},
{ "StarTime",new BsonDocument("$gte",request.Stime)},
{ "EndTime",new BsonDocument("$lte",request.Etime)},
{ "TotalSecond",new BsonDocument(para,request.TotalMin * 60)}
};
var list= collection.Find(document);

其中this不能省略,写法同mongodb命令,使用此写法可以自由拼接参数

猜你喜欢

转载自www.cnblogs.com/ives/p/9580632.html