2016-02-22 3 views
0

Мне нужно установить связь между двумя различными типом узла, как это:родовое ralationship в Neo4j C#

public class Fallow<T,U>: Relationship, 
      IRelationshipAllowingSourceNode<T>, 
    IRelationshipAllowingTargetNode<U> 
{ 
    public Fallow(NodeReference targetNode) 
     : base(targetNode) 
    { 


    } 
    public const string TypeKey = "FALLOW"; 
    public DateTime relationDate { get; set; } 
    public override string RelationshipTypeKey 
    { 
     get { return TypeKey; } 
    } 
} 

У меня есть ошибка:

Error 1 'Biber10.Neo4j.Fallow<T,U>' cannot implement both 'Neo4jClient.IRelationshipAllowingParticipantNode<T>' and 'Neo4jClient.IRelationshipAllowingParticipantNode<U>' because they may unify for some type parameter substitutions C:\Users\turgut\Documents\Visual Studio 2013\Projects\Biber10\Biber10.Neo4j\Fallow.cs 10 18 Biber10.Neo4j 

Как это исправить ?.

Спасибо.

ответ

0

Мы отошли от использования Relationship, как это, лучший пример, что вы пытаетесь сделать, было бы что-то вроде этого:

public class Fallow 
{ 
    public const string TypeKey = "FALLOW"; 
    public DateTime RelationDate { get; set; } 
} 

Используется как так:

//Just using this to create a demo node 
public class GeneralNode 
{ 
    public string AValue { get; set; } 
} 

var gc = new GraphClient(new Uri("http://localhost.:7474/db/data/")); 
gc.Connect(); 

//Create 
var node1 = new GeneralNode { AValue = "val1"}; 
var node2 = new GeneralNode { AValue = "val2" }; 
var fallow = new Fallow { RelationDate = new DateTime(2016, 1, 1)}; 

gc.Cypher 
    .Create($"(n:Value {{node1Param}})-[:{Fallow.TypeKey} {{fallowParam}}]->(n1:Value {{node2Param}})") 
    .WithParams(new 
    { 
     node1Param = node1, 
     node2Param = node2, 
     fallowParam = fallow 
    }) 
    .ExecuteWithoutResults(); 

//Get 
var query = gc.Cypher 
    .Match($"(n:Value)-[r:{Fallow.TypeKey}]->(n1:Value)") 
    .Return(r => r.As<Fallow>()); 

var results = query.Results; 
foreach (var result in results) 
{ 
    Console.WriteLine("Fallow: " + result.RelationDate); 
} 
Смежные вопросы