Search code examples
cypherneo4jclient

Neo4jclient C#: WHERE x IN List


The question is simple. Is it possible to make a WHERE x IN List in Neo4jClient?

Here is an Cypher example:

MATCH (tobias { name: 'Tobias' }),(others)
WHERE others.name IN ['Andres', 'Peter'] AND (tobias)<--(others)
RETURN others

Thank you


Solution

  • Neo4jclient simply wraps the Cypher REST interface, so yes. Just replace the Cypher keywords with their equivalent methods in IGraphClient and pass whatever you want to .Where (). (I also rewrote your query a little but you can ignore that)

    var others = graphClient.Cypher
      .Match("({ name: 'Tobias' })<--(others)")
      .Where("others.name IN ['Peter', 'Andres']")
      .Return(others => ...).Results;
    

    Replace the three dots with what you want to deserialize to, for example others.As<IEnumerable<User>>().