Trying to look at a relationship in a query like this:
var query = _graph.Cypher.Start(
new
{
me = Node.ByIndexLookup("node_auto_index", "id", p.id)
}).Match("me-[r:FRIENDS_WITH]-friend")
.Where((Person friend) => friend.id == f.id)
.Return<FriendsWith>("r");
Here is the FriendsWith class. I can't add a parameterless constructor for FriendsWith, because the base class (Relationship) doesn't have a parameterless constructor.
public class FriendsWith : Relationship,
IRelationshipAllowingSourceNode<Person>,
IRelationshipAllowingTargetNode<Person>
{
public FriendsWith(NodeReference<Person> targetNode)
: base(targetNode)
{
__created = DateTime.Now.ToString("o");
}
public const string TypeKey = "FRIENDS_WITH";
public string __created { get; set; }
public override string RelationshipTypeKey
{
get { return TypeKey; }
}
}
But I get the error "No parameterless constructor defined for this object." when I try to run it. What is the proper way to return a relationship for a query?
Stack trace
at Neo4jClient.Deserializer.CypherJsonDeserializer1.Deserialize(String content) in c:\TeamCity\buildAgent\work\f1c4cf3efbf1b05e\Neo4jClient\Deserializer\CypherJsonDeserializer.cs:line 53
at Neo4jClient.GraphClient.<>c__DisplayClass1d
1.b__1c(Task1 responseTask) in c:\TeamCity\buildAgent\work\f1c4cf3efbf1b05e\Neo4jClient\GraphClient.cs:line 793
at System.Threading.Tasks.ContinuationResultTaskFromResultTask
2.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
FriendsWith
? – veljkozpublic FriendsWith():base(-1){}
– Charlotte Skardon