2
votes

I just started to use a neo4jclient and I am struggling with cypher queries. I used the query from here, but I did not figured out How can I get the results and work with them.

First I put some node in database and then I wanted to retrieve them (in this case one) and I tried this :

var u = client.Cypher
     .Match("(user:User)")
     .Where((User user) => user.Id == 1)
     .Return(user => user.As<User>());

Console.WriteLine(u.Results.ToList().First().Id);

(I am sure that there are nodes in database and also node with Id = 1)

But on the line with Results method I am getting this exception:

SyntaxException: expected START or CREATE "MATCH (user:User)"

I am total beginner with neo4j and I was not able to find out how to access and work with results of query, So I want to ask you for help. Thank you in advance.

2

2 Answers

1
votes

The error you are getting is saying that you need to start your Cypher query with a START or CREATE clause. This indicates to me that you're working against Neo4j 1.9 or below. The START clause only becomes optional in Neo4j 2.0.

If you're starting a new project, I would recommend using Neo4j 2.0. The final release isn't out yet, but the previews are definitely stable enough for you to commence development and the final version will be out very soon.

If you need to use Neo4j 1.9, then you'll need to use the older versions of Cypher queries that include the START clause.

-1
votes

This is a known issue reported 2 hours ago to Neo4jClient team: https://bitbucket.org/Readify/neo4jclient/issue/163/neo4j-v2m6-client-syntax-error

As a workaround try this:

var u = client.Cypher
     .Match("(user:User)")
     .Where("user.Id = {userId}")
     .WithParam(new {userId = 1})
     .Return(user => user.As<User>());