1. Readify
  2. Neo4jClient
  3. Issues

Issues

Issue #66 resolved

Support custom parameters in Cypher fluent queries

Tatham Oddie
created an issue

From http://stackoverflow.com/questions/15636924/how-do-i-pass-relationship-properties-as-parameters-in-the-net-neo4j-client:

I'd like to pass in parameters into a query so that I can use relationship properties in CreateUnique. I'd prefer to use the parameters rather than just doing a string format so that it can protect (Am I right in aassuming parameters are cypher injeciton protected?) against cypher injection.

The query in the question:

var query = client
    .Cypher
    .Start(
        new CypherStartBitWithNodeIndexLookup("left", AUTOINDEX, PrimaryIndexKey, uname),
        new CypherStartBitWithNodeIndexLookupWithSingleParameter("right", AUTOINDEX, luceneQuery)
    )
    .CreateUnique("left-[r:Installed {DeviceId:{DeviceId},OS:{OS}}]->right")
    .Return<Software>("right");

How this could work:

var query = client
    .Cypher
    .Start(
        new CypherStartBitWithNodeIndexLookup("left", AUTOINDEX, PrimaryIndexKey, uname),
        new CypherStartBitWithNodeIndexLookupWithSingleParameter("right", AUTOINDEX, luceneQuery)
    )
    .CreateUnique("left-[r:Installed {DeviceId:{DeviceId},OS:{OS}}]->right")
    .WithParam("DeviceId", 123)
    .WithParam("OS", "Windows 8")
    .Return<Software>("right");

The WithParam method would be supported at any step of the fluent query, and would affect the QueryParameters dictionary that we already track.

Comments (2)

  1. Log in to comment