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命令,使用此写法能够自由拼接参数mongodb

 

//判断时间范围,单位:秒this

var document = new BsonDocument{ { "$where","this.StarTime-this.EndTime>10"}, { "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);
相关文章
相关标签/搜索