我使用db.system.js.save命令
保存了我的地图并减少了功能我想用map reduce调用c#这个函数
MongoClient client = new MongoClient();
MongoServer server = client.GetServer();
MongoDatabase test = server.GetDatabase("test");
MongoCredentials credentials = new MongoCredentials("username", "password");
var databaseSettings = server.CreateDatabaseSettings("test");
var database = server.GetDatabase(databaseSettings);
BsonValue bv = test.Eval("GetSum(3,10)" );
可能吗?
答案 0 :(得分:2)
回答是;
MongoClient client = new MongoClient();
MongoServer server = client.GetServer();
MongoDatabase test = server.GetDatabase("test");
MongoCredentials credentials = new MongoCredentials("username", "password");
var databaseSettings = server.CreateDatabaseSettings("test");
var database = server.GetDatabase(databaseSettings);
BsonValue bv = test.Eval("GetSum",3,10 ); // return stored js function
BsonValue bv1 = test.Eval(bv .AsBsonJavaScript.Code,3,10); // execute jsfunction