Search code examples
neo4jcypherneo4jclient

neo4jclient where clause not putting in parameters


I'm having an issue with the Where clause not pulling out the values and putting them as parameters.

return 
   startingNode
   .StartCypher("startNode")
   .Match(matchQuery)
   .Where<TSourceNode>(otherStartNodes => otherStartNodes.Id != startingNode.Data.Id)                
   .Return<TSourceNode>("otherStartNodes").Results;                        

The Query string comes out looking like "WHERE (Id <> Id)". I can fix the problem easily by not using lambdas and just using the code below but I'm interested to see why it didn't work

.Where("startNode.Id <> otherStartNodes.Id")

I've also tried the below line but that didn't work either.

.Where<TSourceNode, TSourceNode>((otherStartNodes, startNode) => otherStartNodes.Id != startNode.Id)      

Edit Tatham - I've created an issue in Bitbucket for this.

You are correct the right way for the Where clause should be.

.Where<TSourceNode, TSourceNode>((otherStartNodes, startNode) => otherStartNodes.Id != startNode.Id))

Solution

  • Update: This is issue 73, fixed in 1.0.0.525 and above.

    From what I understand of your rather dynamic query, the third option you mentioned (.Where<TSourceNode, TSourceNode>((otherStartNodes, startNode) => otherStartNodes.Id != startNode.Id)) is the correct one.

    This should work. I even added more unit tests in Neo4jClient to assert that it does: https://bitbucket.org/Readify/neo4jclient/commits/cc73ce253ddce89e69785caa68f5e4660a622b96

    Can you explain why you think it didn't work? What was the resulting query text?


    The value you're getting for .Where<TSourceNode>(otherStartNodes => otherStartNodes.Id != startingNode.Data.Id) is wrong. It should evaluate startingNode.Data.Id once in .NET, then send something like WHERE otherStartNodes.Id <> {p1} over the wire. I'll test this separately.