Convert LINQ to MongoDB queries to JavaScript shell

github_icon If you do a lot of work with MongoDB from .NET,
this code should look familiar:

var query =
        from p in mongo.People
        where p.Age > 20 && p.Name.Length >= 2
        orderby p.Age descending
        select p;

But could you answer these questions?

  • What *exactly* does it do on the server?
  • Is it using an index or not?

Well, I just released a new .NET library on GitHub

MongoDB query helper for .NET

Now these questions are easy to answer. For example:

Console.WriteLine( query.ToMongoQueryText() );


{ "Age" : { "$gt" : 20 }, "Name" : /^.{2,}$/s }

Check it out. I hope you find it useful.


Submit a comment

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

You are commenting using your 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