tags:

views:

186

answers:

1

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

A: 

After some more google-ing, I found this:

http://www.claassen.net/geek/blog/2009/09/linq2mongodb-building-linq-provider-for.html

var mongo = new Mongo();
var queryable = mongo["db"]["collection"].AsQueryable();
var in = from d in queryable where d.Key("foo").In("bar", "baz") select d;
Andrei Neagu