2015-04-19 15 views

risposta

0

È possibile utilizzare LINQ

var collection = _db.GetCollection("users"); 
return (from x in collection.AsQueryable() 
     select x["something"]).toList(); 
+4

in MongoDB 2.0 driver, GetCollection tornerà IMongoCollection , non v'è nessun metodo AsQueryable() in IMongoCollection iwaitu

+0

@iwaitu Sembra che abbiano "IMongoCollection" storicamente azzoppato - non è nemmeno "IEnumerable"! Che diamine?! –

6

Si dovrebbe trovare con filtro vuoto come users.Find(new BsonDocument()).ToListAsync();

4

Brutto approccio diretto:

await (await users.FindAsync(_ => true)).ToListAsync() 
+0

la domanda è perché il nuovo driver di mongo ha cambiato la sintassi ma exmaples esistenti sono obsoleti –

Problemi correlati