what’s wrong?
Hi Fabrizio,
The result that you are seeing is the string representation of the cursor returned from your find(). i.e. db.MyDB.find({_id:1}). Eval only returns the cursor, it doesn’t iterate for you. You can try swapping the function content to db.MyDB.findOne({_id:1}) , db.stats() or anything that returns a non-cursor result.
Having said the above, eval command has been deprecated since version 3.0. Also there are performance and concurrency limitations to running JavaScript script inside MongoDB server. Depending on your use case, separating application logic in two places (application code and database) may complicate the logic flow as well.
I would highly recommend to reconsider your stored JavaScript procedure strategy. Utilise the interface provided via MongoDB .Net/C# driver instead, see Query the Collection Tutorial for example to run find().
Regards,
Wan.