2013-09-27 11 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

太棒了,谢谢! –

相关问题