4
votes

I'm new to Neo4j and trying to do a simple Cypher query using a lambda expression in the where clause but for some reason I can't seem to figure out why this isn't working.

Looks like:

class HealthNode { 
    public string Name{get;set;}
    //Other Stuff
}
string Name = "Foobar";

var query = client
    .Cypher
    .Start(new { n = Neo4jClient.Cypher.All.Nodes })
    .Where((HealthNode n) => n.Name == Name)
    .Return<HealthNode>("n");        

If I dump the Text and Parameters I'm getting:

START n=node(*)
WHERE (n.Name! = {p0})
RETURN n
//P0 Foobar

When I execute this, I of course get:

Cypher does not support != for inequality comparisons. Use <> instead

Why in the world is an extra Exclamation point to the name of the variable?

3

3 Answers

0
votes

The ! means that the result will be false if the property doesn't exist. So, if you have more than one type in the graph, and that other type doesn't have a 'Name' property, neo4j won't bother matching.

See Neo4J Documentation for more info.

As to getting the != warning, are you changing the query at all when you paste it? Reformatting it? As I get the same warning if I do:

WHERE (n.Name != {p0})

but don't get any warning, and a successful completion if I use:

WHERE (n.Name! = {p0})
0
votes

I think I found the cause of the problem here:

There was a change made to the 2.0 parser that implements NULL IF by default (instead of returning an error on a missing property) and removes the ! and ? operators since they no longer do anything.

neo4j pull request 1014 I suspect this will break a lot of things and not just Neo4J Client.

0
votes

Fixed in Neo4jClient 1.0.0.625 and above, when talking to Neo2j 2.0.