Try to construct a IMongoQuery document as below but get hit by error "Duplicate element name '$or'.". Any advice, please?
IMongoQuery query = new QueryDocument {
{ flag, true },
{ $or, new BsonArray{
new BsonDocument{{startDate, BsonNull.Value}},
new BsonDocument{{startDate, new BsonDocument{{$lt, DateTime.Now}}}}
}},
{ $or, new BsonArray{
new BsonDocument{{endDate, BsonNull.Value}},
new BsonDocument{{endDate, new BsonDocument{{$gt, DateTime.Now}}}}
}},
};
The query is trying to return documents whose flag is true, plus current time falls in between startdate and enddate, or if documents have no start and end dates defined, they should also be returned.
Appreciate your advice.