0

db.system.js.save コマンドで map と reduce 関数を保存しました。

C#でこの関数をmap reduceと同じように呼び出したい

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)" );

可能です?

4

1 に答える 1

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
于 2013-05-07T08:12:41.883 に答える