Say, I have some POCO
like following.
public class Graph
{
public string Id { get; set; } // Indexed by this
public List<Node> NodeList { get; set; }
}
public class Node
{
public string Id { get; set; }
public string Name { get; set; }
public List<Edge> EdgeList { get; set; }
}
public class Edge
{
public string Id { get; set; }
public double Cost { get; set; }
}
When partially updating my Graph
I want to find an existing Node
in NodeList
by it's Id
, and update it's Name
and Edge
property. I do not want to add new Node
objects in my NodeList
. Only want to update existing ones.
Sofar I've tried:
public void UpdateGraph(string index, Graph graph)
{
var docPath = new DocumentPath<Graph>(graph.Id).Index(index);
try
{
var updateResp = client.Update<Graph, Graph>(docPath, searchDescriptor => searchDescriptor
.Doc(graph)
.RetryOnConflict(4)
.Refresh(true)
);
}
}
In my current implementation as you can see all I am doing is replacing
the old Graph
object. But I want to partially update my Graph
object. I want to send list of Node
object as parameter,
Find those in NodeList
and only update those Node
Objects.
Maybe some thing like the following,
public void UpdateGraph(string index, List<Node> node)
{
//Code here
}