I'm having trouble retrieving matched relationships from a Cypher query.
I have this simple trial code:
var movie = client.Create(new Movie { Title = "The Matrix" });
client.Create(new Actor { Name = "Keanu Reeves" },
new ActedIn(movie, new ActedInPayload { Role = "Neo" }));
client.Create(new Actor { Name = "Hugo Weaving" },
new ActedIn(movie, new ActedInPayload { Role = "Agent Smith" }));
var actorsAndRoles = client
.Cypher
.Start(new { movie = movie })
.Match("actor-[r:ACTED_IN]->movie")
.Return((actor, r) => new
{
Actor = actor.As<Node<Actor>>()
// ActedIn = r.As<?????>()
})
.Results;
Problem is that I can't work out how to cast the r (with the matched relationship).
Tried various ".As" type casts, but none work. Casting to Relationship doesn't work because my relationship class doesn't have a parameterless constructor - but then the Relationship base class doesn't have a parameterless constructor itself, so don't think that would work. Casting to RelationshipReference on the other hand causes an exception. Not casting at all (just returning r) causes a "not supported" exception.
There are some related SO entries about this issue, but the suggested code there either no longer works or is deprecated.
How do I retrieve the matched relationship?