I found a lot of examples of how do use $in in the previous mongodb c# driver, but I can not find any examples on how to do it in the 2.0 version.
Use the AnyIn
operator for the typed version:
Builders<TDocument>.Filter.AnyIn(x => x.Array,searchArray)
There is $in
operator in the driver:
var inValues = new List<string>() { "value1", "value2" };
var filter = Builders<BsonDocument>.Filter.In("Field Name", inValues);
// usage of the filter:
IMongoCollection<BsonDocument> collection = <get your collection here>
var query = collection.Find(filter)
...
where "Field Name" should be replaced with the actual field name used for filtering.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With