Executing User defined functions on MongoDB in C#

43 views Asked by At

I am trying to execute a user defined function on MongoDB from C# using RunCommand() method. But whenever I try to give the name of function or try it with eval it just throws an exception saying expected value but some character found.

Suppose below is my function on mongodb:

add(x1, x2){ return x1+x2;}

I tried executing as follows but failed :

_db.RunCommand($"add({x1},{x2})")

_db.RunCommand($"{ eval: "add({x1},{x2})"}")

_db.RunCommand($"{ $eval: "add({x1},{x2})"}")

0

There are 0 answers