Not sure what that query does, but anyway, when writing queries in
straight JSON you write an AND by simply listing the clauses in a
document (each element is one of the clauses of the AND), and you
write an OR by using the $or operation. See details at:
http://www.mongodb.org/display/DOCS/Advanced+Queries
I used the following statement to see what the JSON equivalent to your
query is:
var indented = new JsonWriterSettings { Indent =
true };
Console.WriteLine(query.ToJson(indented));
Note: your two inner ANDs only have a single argument so the AND part
is optimized away.
and from that I figured out one way that you could create a
QueryDocument directly is using:
var queryDocument = new QueryDocument {
{ "sn", sn },
{ "startDate", new BsonDocument { { "$lte",
DateTime.Parse(startDate) } } },
{ "endDate", new BsonDocument { { "$gte",
DateTime.Parse(endDate) } } },
{ "$or", new BsonArray {
new BsonDocument { { "$sn", sn } },
new BsonDocument { { "startDate", new
BsonDocument { { "$gte", DateTime.Parse(startDate) } } } },
new BsonDocument { { "endDate", new
BsonDocument { { "$lte", DateTime.Parse(endDate) } } } }
}}
};
Console.WriteLine(queryDocument.ToJson(indented));
And compared the output of the two WriteLine statements to verify that
they produced the same query.