2013-09-27 12 views
0

所以我有一個描述關係,像這樣一類:的方法的類型參數不能從使用錯誤推斷創建關係

public class GraphRelationship<TObject> : Relationship<RelationshipObject>, IRelationshipAllowingSourceNode<TObject>, IRelationshipAllowingTargetNode<TObject> 
    { 
     string RelationshipName; 

     public GraphRelationship(string RelationshipName, NodeReference targetNode, RelationshipObject relationshipTypeObject) 
      : base(targetNode, relationshipTypeObject) 
     { 
      this.RelationshipName = RelationshipName; 
     } 

     public override string RelationshipTypeKey 
     { 
      get { return RelationshipName; } 
     } 
    } 

現在我有,我想用它來創建一個方法上面提到的類的一個實例,但是我得到這個The type arguments for method cannot be inferred from the usage錯誤。

這裏是方法:

public RelationshipReference CreateObjectRelationship(string relationshipType, string parentObjectId, string childObjectId, RelationshipObject relationshipProperties) 
{ 
    RelationshipReference relationshipReference = 0; 

    NodeReference parentNodeReference = GetObjectReference(parentObjectId); 
    NodeReference childNodeReference = GetObjectReference(childObjectId); 

    //This is where the error is 
    relationshipReference = GraphConnection.CreateRelationship(parentNodeReference, new GraphRelationship<RelationshipObject>(relationshipType, childNodeReference, relationshipProperties)); 

    return relationshipReference; 
} 

enter image description here

我敢肯定,這是一個很重要的問題,但我怎麼解決這一問題?

回答

1

所以我固定它,我NodeReferences是類型的需要<TObject>

NodeReference<TObject> parentObjectReference = GetObjectReference(Id);

1

它看起來就像你試圖使一個通用實現的一個通用的關係,與Neo4jClient的一個過時部分API。

使用Cypher。 ;)

+0

API的哪些部分已經過時,我們正在使用客戶端相當廣泛。 –

+1

基本上任何在代碼路徑中都沒有「Cypher」的地方。這與Neo4j本身的方向一致。 本週,我將與其他司機作家一起在聖弗蘭的Neo辦公室花費幾天的時間,然後花時間就此發佈更好的指導。 –

+0

太棒了,謝謝! –

相關問題