I want to run mongo find query with foreach operation directly on mongo server because through foreach operation I want to insert documents into other collection with extra properties. My mongo query is below
This is successfully run into mongo shell, now I want to execute that script from c# application with modify object value dynamically. I was hoping it would be able to parse those queries and pass them off to database.RunCommand but I have not been able to make any progress.
That code fails on the call to Deserialize with this error message: [Additional information: JSON reader was expecting a value but found 'db'.] which makes perfect sense because the script is not valid JSON.
So I'm having trouble parsing the script into something that can be executed.