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

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -