Search code examples
c#neo4jneo4jclient

Trying to do Unwind and Merge on the same command On Neo4J C# Client


I am trying to create a batch of nodes from list but I want to make sure those nodes are not already exists in the neo4j db, I manage to do it on a single node but I also want to enable it for batch of nodes I have tried this command:

    graphClient.Cypher
        .Unwind(NodesList, "singleNode")
        .Merge("(node:Node {Id : {innerNode}.Id})")
        .OnCreate()
        .Set("innerNode= singleNode")
        .WithParams("innerNode")
        .ExecuteWithoutResults();

and I am getting a error of "Parameter Count Mismatch"

  • I am still new to Neo4J and I havn't found any one with the same problem at c# language

Thanks a lot from advanced.


Solution

  • I'm assuming that NodesList is a list of the nodes you're wanting to MERGE - in essence, you need to drop the innerNode from your query, and use the singleNode you're passing in from the UNWIND:

    graphClient.Cypher
        .Unwind(NodesList, "singleNode")
        .Merge("(node:Node {Id : singleNode.Id})")
        .OnCreate()
        .Set("node = singleNode")
        .ExecuteWithoutResults();
    

    This should get you there