Search code examples
neo4jcypherneo4jclient

c# NEO4J v3 can't create relationship


I have a c# project that I'm working with NEO4J 2.3.2 , after updating to version 3 I start to see that my system always fail creating relationships . thus is my code

  View userView = new View { parent = parent, timestamp = currentTime };
  WebApiConfig.GraphClient.Cypher
             .Match("(user123:BaseUser{guid: '" + isAuto + "'})", "(y:YoutubeItem{videoId: '" + itemid + "'})")
             .CreateUnique("user123-[r:VIEW]->y")
             .Set("r = {userView}")
             .WithParam("userView", userView)
             .ExecuteWithoutResults();

and this is the exception

"SyntaxException: Parentheses are required to identify nodes in patterns, i.e. (user123) (line 2, column 15 (offset: 127))\n\"CREATE UNIQUE user123-[r:VIEW]->y\r\"\n               ^" 

and when i go back to the old version everything is working well, what should i do?


Solution

  • Cypher now enforces the requirement that nodes must be surrounded by parentheses.

    So, in your query, the CreateUnique line needs to look like this:

    .CreateUnique("(user123)-[r:VIEW]->(y)")
    

    By the way, you should be using parameters for injecting the isAuto and itemId values. You are already doing that with userView.