所以我一直在使用 C# 的 Neo4jClient 库,我对这两个世界都很陌生。
我在这里有这个 POCO:
public class SetEntity
{
public string GUID { get; set; }
public string Name { get; set; }
public string Type { get; set; }
public string CreatedDate { get; set; }
}
这个对象类用于各种方法,特别是用于创建两个节点之间的关系,但是我必须明确说明使用哪个 POCO 来创建它IRelationshipAllowingSourceNode<SetEntity>
和IRelationshipAllowingTargetNode<EntityInstance>
. 下面是处理该问题的整个类。
class GraphRelationshipEntityInstanceToSetEntity : Relationship, IRelationshipAllowingSourceNode<EntityInstance>, IRelationshipAllowingTargetNode<SetEntity>
{
string RelationshipName;
public GraphRelationshipEntityInstanceToSetEntity(NodeReference targetNode)
: base(targetNode)
{
}
public GraphRelationshipEntityInstanceToSetEntity(string RelationshipName, NodeReference targetNode)
: base(targetNode)
{
this.RelationshipName = RelationshipName;
}
public override string RelationshipTypeKey
{
get { return RelationshipName; }
}
}
有没有办法可以将<SetEntity>
任何其他对象传递到IRelationshipAllowingSourceNode<Object>
. 我认为没有必要为每个与另一个节点类型有关系的节点类型创建这个类。