Deserialize cosmo-db response using Gremlin.Net

Viewed 427

I am using Gremlin.net to fetch data from cosmo-db. Now the issue is I can't figure out the best approach to parse the response in my Model.

Here is the code to get data:

  var query= "g.V('" + id+ "')";
  var profileData = await gremlinClient.SubmitAsync<dynamic>(query);

Now the response return is of type Dictionary<string, object> and my model is:

public class Model {
   public string id{ get; set; }
   public string username{ get; set; }
   public string address{ get; set; }
}

Now except for id, other properties are mapped inside properties key. So what is the best way to parse the response? I have tried something like:

 foreach (var result in profileData)
 {
     var id = result["id"].ToString();
     var properties = result["properties "] as Dictionary<string, object>;
     var username = ((Dictionary<string, object>)properties["username"].First())["value"].ToString();
 }

Now the issue is it cannot resolve .First() or any other linq function. So how can I fix this or if there other better approach.

0 Answers
Related