Search code examples
c#.netneo4jcypherneo4jclient

Neo4j .NET Client Execute String Cypher Queries


Is it possible to execute CYPHER queries as just plain old strings using the Neo4j .NET Client or any other module?

For instance, if I want to add some nodes to my graph database and already had the statements assembled, is there a means to execute a string:

CREATE (n:Edit {name:"L-1154LX"});

I'm looking to batch process a list of CREATE CYPHER queries that have already be created.


Solution

  • Officially documented at https://github.com/Readify/Neo4jClient/wiki/cypher#manual-queries-highly-discouraged

    However, this will be bad for performance, and risky for security.

    It's bad for performance, because it will have to re-parse every query. You should use parameters, like in the example at https://github.com/Readify/Neo4jClient/wiki/cypher-examples#create-a-user This way, the query text remains consistent, and just the parameter varies, so you don't incur the query compilation cost on every call.

    It's risky for security, because you can easily get the encoding wrong, and expose yourself to injection risks.

    So, please don't run manual queries unless you really understand what you're doing. They're hidden on purpose.