11

is it possible to use linqpad with MongoDB? or any other tool for that matter that allows you to use linq to run adhoc queries on mongo.

I've tried using the shell to write the queries in json, but the brackets, quotes, colons are driving me absolutely insane.

If there isn't a tool, I'm going to resort to writing my queries in c# and compiling/running.

Jamona Mican
  • 1,574
  • 1
  • 23
  • 54

2 Answers2

6

It seems other are able to do it as the choosen answer of this question indicates: are adhoc queries/updates starting to kill your productivity with MongoDB?

And here is a tutorial showing how to set it up.

Community
  • 1
  • 1
tobsen
  • 5,328
  • 3
  • 34
  • 51
5

I've written an adapter for LinqPad to use the official 10gen driver. It's available as an open source project on my github:

https://github.com/gburgett/LinqPad-mongo-driver

It allows you to map collections to C# types loaded from your own .dll assemblies. The collections will then appear as properties of type MongoCollection<TColl> which you can use LINQ queries against. It will even expose in the "SQL" tab the JSON of the query that was executed.

I've been using this in my office for some time, and have over time added support for a variety of usages that we have needed in our office, for instance custom serializers and other once-per-appdomain initializations.

Gordon Burgett
  • 1,482
  • 11
  • 15
  • How do you produce the .lpx file? – Anton Georgiev Mar 17 '14 at 16:30
  • 2
    Zip the output directory, then rename the .zip to .lpx. The output directory should contain the following files: header.xml LinqPadMongoDriver.dll MongoDB.Bson.dll MongoDB.Driver.dll – Gordon Burgett Apr 03 '14 at 17:50
  • @GordonBurgett I wold suggest you to add this piece of info to the ReadMe, you may even go a step ahead and add it as a PostBuild event or a MsBuild Task – yoel halb Apr 26 '17 at 16:07