想看看在查詢這樣的關係:Neo4jClient - 查詢關係
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");
這裏是FriendsWith類。我無法爲FriendsWith添加無參數構造函數,因爲基類(關係)沒有無參數構造函數。
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; }
}
}
但我得到錯誤「沒有無參數的構造函數爲這個對象定義。」當我嘗試運行它。什麼是返回查詢關係的正確方法?
堆棧跟蹤
在Neo4jClient.Deserializer.CypherJsonDeserializer 1.Deserialize(String content) in c:\TeamCity\buildAgent\work\f1c4cf3efbf1b05e\Neo4jClient\Deserializer\CypherJsonDeserializer.cs:line 53 at Neo4jClient.GraphClient.<>c__DisplayClass1d
1.b__1c(任務1 responseTask) in c:\TeamCity\buildAgent\work\f1c4cf3efbf1b05e\Neo4jClient\GraphClient.cs:line 793 at System.Threading.Tasks.ContinuationResultTaskFromResultTask
2.InnerInvoke() 在System.Threading.Tasks.Task.Execute()
滿堆棧跟蹤? FriendsWith的外觀如何? – 2013-05-08 06:55:16
也許你錯過了類「FriendsWith」的默認(無參數)構造函數? – veljkoz 2013-05-08 15:05:28
你可以添加一個默認的構造函數,你只需將一個虛擬值傳遞給基類構造函數,就像這樣:public FriendsWith():base(-1){} – 2013-08-27 13:16:17