Search code examples
c#neo4jclient

Neo4jClient c# Where Has set dynamically


I have this query:

var query = client.Cypher
               .Match("(store:Store)")
               .Where("has(store.en_GB)")
               .Return<Store>("store");

        return query.Results.ToList();

What I want is for 'en_GB' to be able to be set from a variable called locale, but I have no idea how this would be possible.

I thought it may be as simple as

.Where("has(store.{param})")
.WithParam("param",region)

but that didn't work, so is it possible. please help.


Solution

  • Something like this?

    var locale = "en_GB";
    
    var query = client.Cypher
                   .Match("(store:Store)")
                   .Where(String.Format("has(store.{0})", locale))
                   .Return<Store>("store");
    
            return query.Results.ToList();