Get a list of documents from Mongo DB
Posted
by Andrei Neagu
on Stack Overflow
See other posts from Stack Overflow
or by Andrei Neagu
Published on 2010-05-28T09:20:44Z
Indexed on
2010/05/29
7:02 UTC
Read the original article
Hit count: 316
Hello,
I want to do something like this:
List<int> fff = new List<int>();
fff.Add(1);
fff.Add(2);
fff.Add(5);
Mongo m = new Mongo();
m.Connect();
var dataBase = m.GetDatabase("database");
var collection = dataBase.GetCollection("coll");
IMongoQuery queryable = collection.AsQueryable();
MongoQueryProvider prov = new MongoQueryProvider(collection);
var query = new MongoQuery(prov);
var ffppp = from p221 in query where fff.Contains((int)p221["oid"]) select p221;
This throws this error : The method 'Contains' could not be converted into a constant.
I saw that mongo has an operator $in. Does any one know how can I use it from c#? (http://www.mongodb.org/display/DOCS/Advanced+Queries)
Thanks
© Stack Overflow or respective owner