ra0o0f / arangoclient.net

ArangoDB .NET Client with LINQ support
Apache License 2.0
99 stars 37 forks source link

Update fails with error "The given key was not present in the dictionary" when used on object retrieved via traversal. #116

Open Rleahy opened 5 years ago

Rleahy commented 5 years ago

The key it prints out in that error message seems to be a serialisation of the entire object.

The object that causes the error is retrieved initially via this function which is part of the Target Object.

 public List<TargetStructure> GetStructures(){

  var result = GraphDB.DB.Traverse<TargetStructure, StructureOf>(new TraversalConfig
        {
            StartVertex = GetHandle(),
            GraphName = "StructureOf",
            Direction = EdgeDirection.Inbound
        });

    TargetStructure[] structs = result.Visited.Vertices.ToArray();
    List<TargetStructure> targets = new List<TargetStructure> ( );
    for(int i = 0; i < structs.Length; i++)
    {

        if( structs[i].LogicDataType=="TargetStructure" )
        {
            targets.Add(structs[i]);
        }

    }

    return targets;
    }

Trying to modify then update the object that gets returned causes the error.

If however i extract the key from the object this function returns and retrieve it fresh from the database then modify and update that instance of the object it works without issue.

Something about my traversal function seems to be returning an object that is broken in some way.

For reference the traversal function is supposed to get all TargetStructure documents connected to its self via StructureOf edges, which go from the TargetStructure to the Target Object.