mongodb - C# Mongo RunCommandAsync -
is possible run
db.users.createindex({"firstname" : 1, "lastname": 1});
from runcommandasync there examples of can done command.
as test tried run through exception
var indexcommand = new bsondocumentcommand<bsondocument>(new bsondocument{ {"getindexes", "users"} }); var results = await database.runcommandasync(indexcommand);
i know can , create indexes c# drivers, keep script in sync between want build indexes through c# , want handle directly on db.
you try alternative method. if see runcommandasync expected bsondocument. see unit test runcommandasync
assuming using mongodb 3.0, can consider code below alternative?
using (var results = await context.users.indexes.listasync()) { while (await results.movenextasync()) { foreach (var current in results.current) { system.diagnostics.debug.writeline(current["name"].asstring); } } }
Comments
Post a Comment