Here, as if you would like to receive this exact request:
var qType1 = Query.EQ("$elemMatch",
BsonValue.Create(Query.And(Query.EQ("Type", 1),
Query.EQ("Value", "a"))));
var qType2 = Query.EQ("$elemMatch",
BsonValue.Create(Query.And(Query.EQ("Type", 2),
Query.EQ("Value", "b"))));
var query = Query.All("Properties",
new List<BsonValue> {
BsonValue.Create(qType1),
BsonValue.Create(qType2)
});
The routine is that although many parameters for various methods Queryare expected BsonValueinstead of queries, you can create an instance BsonValuefrom the instance Queryby doing something like:
var bv = BsonValue.Create(Query.EQ("Type", 1));
The actual request sent exactly matches your original request:
query = {
"Properties": {
"$all": [
{ "$elemMatch": { "Type": 1, "Value": "a" }},
{ "$elemMatch": { "Type": 2, "Value": "b" }}
]
}
}
( $all, , -, = "/questions/478816/multiple-elemmatch-expressions-for-matching-array-values-using-all-in-mongodb" > ).