Родственные отношения в 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

Как мне это исправить?

Благодарю.

1 ответ

Решение

Мы отошли от использования 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);
}
Другие вопросы по тегам