I am trying to import N nodes in to neo4j using the neo4jclient. I am using a neo4j cluster hosted in Azure so I must use the Bolt protocol. So I am using the RC1 of neo4jclient.
Based on examples that I will include below I have the following code:
BoltGraphClient client =
new BoltGraphClient(new Uri("bolt://myserver:7687"), "neo4j", "mypwd");
client.Connect();
var nodes = new List<myNode>()
{
new myNode()
{
id = "a",
patientKey = "aaa",
patient_fname = "John",
patient_lname = "Doe"
},
new myNode()
{
id = "b",
patientKey = "bbb",
patient_fname = "Jane",
patient_lname = "Doe"
}
};
client.Cypher
.Create("(n:Node {nodes})")
.WithParams(new { nodes })
.ExecuteWithoutResults();
I am getting the following error:
Newtonsoft.Json.JsonSerializationException occurred HResult=0x80131500 Message=Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'System.Collections.Generic.Dictionary`2[System.String,System.Object]' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly. To fix this error either change the JSON to a JSON object (e.g. {"name":"value"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array.
I believe that I have followed the following answer that is supposed to work: Batch insert nodes and relations neo4jclient
I am using Neo4j 3.2.6, Neo4jClient 3RC1 and c# 4.6
If all looks good then I will create a defect for Neo4jClient.
Neo4jClient 3.0.0-RC2
has just been published. I can't get the query you specifically have to run, so I'm going to play with that, but I get the same error from both Neo4jClient
and the official Neo4j.Driver
so I assume it's a change that means that Cypher no longer works.
However, you will find with RC2
you can do:
client.Cypher
.Unwind(nodes, "node")
.Create("(n:Node)")
.Set("n = node")
.ExecuteWithoutResults();
which is the way I would do what you're trying to do.
User contributions licensed under CC BY-SA 3.0