Select Query in mongo db in c# using json query


See MongoDB offers a rich query environment with lots of features.

Queries in MongoDB are represented as JSON-style objects, very much like the documents we actually store in the database.  

See the below example

Like sqlserver we have  select * from things where x=3 and y=
"foo"

In mongo query we have to write

db.things.find( { x : 3, y : "foo" } );

NOw to find all document where j is not equal to 3 and k is greater than 10, you'd query like so:
db.things.find({j: {$ne: 3}, k: {$gt: 10} });
Ebook Download
View all
Learn
View all