Simple-MongoDB – Simplified Querying

I just checked in some code to simplify querying. I will just let the code speak for itself.

var q = new Query()["Name"].In("Daniel", "Sue").And("Age").Gt(21).And().Lt(29);
var persons = entityStore.Find(q.ToString());

So far it only supports:

  • $in
  • $where
  • $lt
  • $lte
  • $gt
  • $gte

More info about the operators

I will continue the work with the inner design of this Querying-code, but the API will be the same. I will of course add more operators to.


5 thoughts on “Simple-MongoDB – Simplified Querying

  1. Pingback: Simple-MongoDB – Querying « Daniel Wertheim

  2. Hi, I really like using your library. But I can’t get this code sample to work. The Query calls require a , and so I get a compiler error. I’d really like to be able to use anonymous objects since some of the docs in my collection vary in structure. Is there a different code branch I need to install?

    Also, is there a way in Simo to get back just a raw JSON string in a query? That would be nice so I can pass it back down to the browser. (I’m using Simo with ASP.NET MVC.)


  3. Actually, I take that back — the error I’m getting is this:

    Pls.SimpleMongoDb.Querying.Query.Query() is inaccessible due to the protection level.

    Since I have the source, can I just change it to public to make it work?

  4. Hi again, looks like I found a different way to do what I need. I just created an empty class that matches the name of the collection:

    class testcollection { };

    From there I can just use the session API:

    var sessionFactory = new SimoSessionFactory();
    using (var session = sessionFactory.GetSession(“Pls.Simo.GettingStarted”)) {
    var db = session[“test”];
    var collection = db.GetCollection();
    var result = collection.Find();
    foreach (var doc in result) {

    It works!

    • Great that it worked out. You do know that I haven’t put any time to the driver in a long time? I might pick it up again and do some adjustments: perf, json-driver, lambda expressions. Interested in joining? Just for fun.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s