c# - IDictonary<string,object> object has multiple objects, how to seperate? -


i'm develop website asp.net mvc4 , mongodb database. microsoft membership provider support sql-db's, i've use membership provider. decided use extendedmongomembership provider. worked long had no additional user properties passed during account creation. tried add additional properties e-mail, functionality of createuserrow function throws , exception. i've downloaded source , try fix it. therefore have separate objects inside of objects, seems way how necessary data passed function.

 public bool createuserrow(string username, idictionary<string, object> values)     {         string usertablename = "users";         list<bsonelement> elements = new list<bsonelement>();         elements.add(new bsonelement("username", username));         elements.add(new bsonelement("_id", getnextsequence("user_id")));         if (values != null)         {            // here i'm facing problem have property names            // , values add them elements list            // idictionary unfortunately not build in way            // propertyname,value entries in easy way          }          var collection = _provider.getcollection(usertablename);         var result = collection.insert(new bsondocument(elements.toarray()));         return result.lasterrormessage == null;     } 

the idictonary contains 4 keys named (comparer,count,keys,values), key names , count fixed. property name(s) write db stored single objects inside of object value key "keys" inside dictonary. same applies values db, these stored inside object value key "values". problem have no idea how separate these objects. here picture shows structure of dictionary during debug session.

http://i.stack.imgur.com/h4z7i.jpg how can access objects inside of objects stored values?

edit: found way, there better 1 ?

        var propnames = ((ienumerable<object>) values["keys"]).toarray();         var propvalues = ((ienumerable<object>)values["values"]).toarray();         dynamic test;         (int = 0; < propnames.count(); i++)         {             type type = propvalues[i].gettype();              test = convert.changetype(propvalues[i], type.underlyingsystemtype);             //bsonvalue bsonvalue = test bsonvalue;             elements.add(new bsonelement(propnames[i] string,test ));         } 


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -