0

I am building a .NET application which works as IDE for MongoDB. Here user can enter raw MongoDB query/command.

For example:

db.getCollection('Employee').find({
     "_id" : ObjectId("5f70db8e04f2f92d00123456")
})

Note: Above code is just for example. The commands vary depending on user's input.

This works fine in Mongo shell.

I tried using MongoDB Driver but it does not support raw MongoDB commands.

Is there a way to achieve using C#?

Also are there any third party libraries which executes raw mongodb commands?

  • Did you look at [mongodb blog](https://www.mongodb.com/blog/post/quick-start-c-and-mongodb--read-operations)? is this what you are looking for? – Ido Jan 08 '21 at 13:43
  • 1
    you can use the original mongo cli , here is how to run external command from c# : https://stackoverflow.com/questions/1469764/run-command-prompt-commands – R2D2 Jan 08 '21 at 13:45
  • @kiko075. I tried using external command from the provided link. But still facing issues. Once I start the process and connect to mongo I don't get the output back. As a result I cannot query the MongoDB. I tried searching different ways to solve this but no luck. Since mongo is widely used I hope there could be a possibility to connect to mongoshell and execute raw mongo queries. – Anirudh Ani Jan 09 '21 at 12:07
  • Basically I want to build a Mongo GUI application similar to Robo 3T. I want to implement the same way they provide mongo shell UI where user can enter any mongo command and execute. – Anirudh Ani Jan 09 '21 at 12:14
  • another info how to get output messages(bear in mind in mongo cli you can suppress with --quiet some messages ): https://stackoverflow.com/questions/4291912/process-start-how-to-get-the-output – R2D2 Jan 09 '21 at 12:16

0 Answers0