c# - FindAll in MongoDB .NET Driver 2.0 -


i want query mongodb collection without filter mongodb .net driver 2.0 didn't find way. have following workaround looks weird :d

var filter = builders<foobar>.filter.exists(x => x.id); var foobars = await _foobarcollection.find(filter)     .skip(0)     .limit(100)     .tolistasync(); 

is there way issue queries without filter in mongodb .net driver 2.0?

you can't use find without filter.

you can use filter passes everything:

var findfluent = await _foobarcollection.find(_ => true); 

or can use empty document equivalent:

var findfluent = await _foobarcollection.find(new bsondocument()); 

they have added empty filter available in newer versions of driver:

var findfluent = await _foobarcollection.find(builders<foobar>.filter.empty); 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -