Reputation: 131
I have a collection "foo":
db.foo.insert({a:[1, 10]})
db.foo.insert({a:[4, 6]})
and a query:
db.foo.find({a: {$elemMatch: {$gte: 5, $lte: 7}}})
and result is:
{a: [4, 6]}
My question is how to use Query.ElemMatch()
in this situation?
Upvotes: 1
Views: 1254
Reputation: 312149
You can use C#'s collection initializer syntax to clean it up a bit:
Query.ElemMatch("a", new QueryDocument {
{"$gte", 5},
{"$lte", 7}
})
Upvotes: 2
Reputation: 131
I found a solution for my problem and hope it's useful for someone
Query.ElemMatch("a", Query.And(new QueryDocument("$gte", 5), new QueryDocument("$lte", 7)))
Upvotes: 1