Is it possible to get the data type of mongodb collection fields using c#? -


i need create datatable stores result of mongodb query using correct data type of fields (string ,double...). here code using here specifying type of created column string type need find way correct type of field:

        var connectionstring = "mongodb://localhost";         var client = new mongoclient(connectionstring);         var server = client.getserver();         var database = server.getdatabase("test");         var collection = database.getcollection("doc1");          datatable dt;         datacolumn column;         int = 0;          dt = new datatable();         string map = @"function() {     (var key in this) { emit(key, null); }    }";         string reduce = @"function(key, stuff) { return null; }";         string finalize = @"function(key, value){        return key;    }";         mapreduceargs args = new mapreduceargs();         args.finalizefunction = new bsonjavascript(finalize);         args.mapfunction = new bsonjavascript(map);         args.reducefunction = new bsonjavascript(reduce);         var results = collection.mapreduce(args);         list<string> fields = new list<string>();         foreach (bsonvalue result in results.getresults().select(item => item["_id"]))         {             fields.add(result.asstring);         }           foreach (string p in fields)         {// here need add correct type of field not string type             column = new datacolumn(p, type.gettype("system.string"));             dt.columns.add(column);             i++;         } 


Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -