Search code examples
neo4jcypherneo4jclient

DEBUG Query Output when using Neo4jClient


I want to visualize the query that Neo4JClient generates for my code.

Is there any way to get the Cypher Query that has been translated.

I tried using the following construct, but it returns an error saying that a void return cannot be assigned to a intrinsic local variable.

var qry= client.Cypher
    .Merge("(dataspace:DataSpace { DataSpaceName: {dataspacename} })")
    .OnCreate()
    .Set("dataspace = {newDataSpace}")
    .WithParams(new {
        dataspacename = newDataSpace.DataSpaceName,
        dataspacedescription = newDataSpace.DataSpaceDescription,
        newDataSpace
        }
    )
    .ExecuteWithoutResults();

Errror returned : Compiler Error Message: CS0815: Cannot assign void to an implicitly-typed local variable

Thanks in advance for your help.


Solution

  • You need to grab the query before you execute it:

    var query = client.Cypher
        .Merge("(dataspace:DataSpace { DataSpaceName: {dataspacename} })")
        .OnCreate()
        .Set("dataspace = {newDataSpace}")
        .WithParams(new {
            dataspacename = newDataSpace.DataSpaceName,
            dataspacedescription = newDataSpace.DataSpaceDescription,
            newDataSpace
            }
        )
    

    There are more specific notes in the documentation: https://github.com/Readify/Neo4jClient/wiki/cypher#debugging