2

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?

Nav
  • 95
  • 10
  • Can you put the code around this up as well? i.e. what is the `child` object? – Charlotte Skardon Sep 02 '14 at 07:20
  • I was just starting with a void method, the only thing other than this is the method signature which accepts a sting value defined as child. but I added where I was with it at the time – Nav Sep 02 '14 at 15:01

1 Answers1

3

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.

Charlotte Skardon
  • 6,220
  • 2
  • 31
  • 42