mongodb-csharp


How do I use in $in operator using the 2.0 version of the C# mongodb driver?


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)
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)));
Or, how about this
var ft = new BsonDocument("ListOfString", new BsonDocument("$in", varString));
var result = myContext.myPOCO.Find(ft);

Related Links

MongoDB C# driver throws timeout exception when trying to connect to replica set
Serialize Dictionary<long, VALUE> to BSON documents
Using a Regex against a simple list with `ElemMatch` in MongoDB .NET
projection wont work in mongodb c# driver
BsonClassMapSerializer already registered for AbstractClassSerializer
MongoDb C# Driver 2.0 Coalesce (or equivalent)?
MongoDB dynamic update of collection when changes occurs in another collection
MongoDB C# 2.0 TimeoutException
MongoDB C# 2.0 upgrade
Searching a MongoDB collection from the end (c#)
Handle extra elements outside of deserialized class
ASP.NET 5 with MongoDB
Store same fields twice during serialization
BsonDefaultValue set to empty list
Don't overwrite extra fields when serializing BSON?
MongoDB C# - how to save arbitrary JSON document as dynamic type?

Categories

HOME
embedded
cobalt
delphi-7
pagination
redux-form
components
devise
javacc
rom
3d-reconstruction
data-visualization
google-cloud-datalab
nstableheaderview
reactive-programming
mel
plist
siddhi
opengl-es-3.0
automatic-ref-counting
altera
azure-powershell
package.json
swagger-2.0
topology
scriptella
epsilon
xunit
entity-relationship-model
fractions
jaws
sqsh
finagle
alm
send
android-sugarorm
python-import
least-squares
engine.io
swagger-php
kill
comparison-operators
dbnull
http-request
show-hide
double-click
serde
excel-dna
payload
swingworker
cronexpression
centrifuge
mta
clipboard.js
cfchart
jaunt-api
concurrentmodification
google-books
cgi-bin
canalyzer
jdk1.7
baasbox
branch-and-bound
grouping-sets
linkedin-jsapi
create.js
twitter-bootstrap-rails
ebay-lms
jquery-1.9
virtual-pc
idn
wcf-configuration
virtualpathprovider
jquery-address
convention
workflow-services
mtu
nhprof
vs-android
unmanagedresources
httpcookie
netbeans6.1

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App