问题
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.
回答1:
Use the AnyIn
operator for the typed version:
Builders<TDocument>.Filter.AnyIn(x => x.Array,searchArray)
回答2:
I was able to figure it out. Here is how to define the Bson document for the Find method:
BsonDocument bson = new BsonDocument("_id", new BsonDocument("$in", new BsonArray(vins)));
回答3:
Or, how about this
var ft = new BsonDocument("ListOfString", new BsonDocument("$in", varString));
var result = myContext.myPOCO.Find(ft);
来源:https://stackoverflow.com/questions/33393696/how-do-i-use-in-in-operator-using-the-2-0-version-of-the-c-sharp-mongodb-driver