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

阅读 189

2022-07-28

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

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

 

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

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

 

留待后查,同时方便他人


精彩评论(0)

0 0 举报