Assuming a graph like this:

You would use a Gremlin query like this to retrieve all of the cars, for all users:
g.v(0).out('HAS_USER').out('HAS_CAR')
Now, lets filter it down to just the red cars:
g.v(0).out('HAS_USER').out('HAS_CAR').filter { it.Color == "Red" }
Finally, you want the users instead of the cars. It's easiest to think of Gremlin working like an actual gremlin (little creature). You've told him to run to the users, then down to each of the cars, then to check the color of each car. Now you need him to go back to the users that he came from. To do this, we put a mark in the query like so:
g.v(0).out('HAS_USER').as('user').out('HAS_CAR').filter { it.Color == "Red" }.back('user')
To write this in C# with Neo4jClient is then very similar:
graphClient
.RootNode
.Out<User>(HasUser.TypeKey)
.As("user")
.Out<Car>(HasCar.TypeKey, c => c.Color == "Red")
.BackV<User>("user")
The only difference here is that you need to use BackE
or BackV
for edges and vertexes respectively intead of just Back
. This is because in the staticaly typed world of C# we need to use different method names to be able to return different enumerator types.
I hope that helps! :)
--
Tatham