Reputation: 95
I'm trying to programmatically save information to a Neo4J DB using the Neo4Jclient.
I've been trying to follow the examples but it doesn't seem to be working.
I've created a database connection which seems to work, but my code won't compile due to the below line..
public void SaveNewRootItem(string child)
{
client = new GraphClient(new Uri([ConnectionStringhere]));
client.Connect();
client.Cypher
.Create("(m:LinkItem {child})")
.WithParams("child", child);
}
According to the examples on the wiki for the opensource repo I should be providing parameterised information in "WithParams".
What am I doing wrong?
Upvotes: 2
Views: 175
Reputation: 6280
I think I see what you're doing, assuming child
exists, you need to do a couple of changes.
First, you'll want to use WithParam
not WithParams
, and after that, to get it into the DB you'll need to ExecuteWithoutResults()
, so you're query would look like:
client.Cypher
.Create("(m:LinkItem {child})")
.WithParam("child", child)
.ExecuteWithoutResults();
If you did want to use WithParams
you have to supply a dictionary:
client.Cypher
.Create("(m:XX {child})")
.WithParams(new Dictionary<string, object>{{"child", child}})
.ExecuteWithoutResults();
Generally that's useful if you've got a lot of parameters in one query, it all boils down to the same regardless.
Upvotes: 3