Search code examples
c#.netlinqgremlinjanusgraph

Gremlin.Net Casting from Enumerable.SelectIListIterator object to real type


I don't know if my question is about c# and casting or related to Gremlin.net Library return Types. I am using this query to get vertices with their db ids.

 g.V().As("vertex").ValueMap<IDictionary<string, object>>()
  .As("properties").Select<object>("vertex", "properties")
  .ToList()

properties is a list of attribute of the vertex. when I try to get the value of any property I found that its type is object with the below definition
property.Value = {System.Linq.Enumerable.SelectIListIterator< Newtonsoft.Json.Linq.JToken, object>}

I can't find a way to cast it to get the value. Thanks in advance.


Solution

  • To get the value from {System.Linq.Enumerable.SelectIListIterator< Newtonsoft.Json.Linq.JToken, object>} object you can use:

    (property.Value as IEnumerable<object>).Cast<object>().ToList() this will return List< object>