代码之家  ›  专栏  ›  技术社区  ›  Z.Tom

如何使用neo4jclient通过展开添加边?

  •  1
  • Z.Tom  · 技术社区  · 10 年前

    节点已存在。 我试图通过展开来添加边,但我的函数 importBuyConnectionIntoNeo4j 不起作用,

    有人能帮我吗?

    数据结构:

    class Connection
    {
        private string type;
    
        public string Type
        {
            get { return type; }
            set { type = value; }
        }
    
        private string source;
    
        public string Source
        {
            get { return source; }
            set { source = value; }
        }
    
        private string target;
    
        public string Target
        {
            get { return target; }
            set { target = value; }
        }       
    }
    
    class BuyConnection:Connection
    {
    
    }
    

    我的功能:

        public void importBuyConnectionIntoNeo4j(List<BuyConnection> connectionList)
        {
            GraphClient client = createConnectionToNeo4j();
            client.Cypher
                .Unwind(connectionList, "connection")
                .Match("(source:Person),(target:Vegetable)")
                .Where("source.Name=connection.Source AND target.Type=connection.Target")
                .Create("(source)-[:Buy]->(target)")
                .ExecuteWithoutResults();
        }
    
    1 回复  |  直到 10 年前
        1
  •  1
  •   Charlotte Skardon    10 年前

    我认为问题在于你 .where 文本:

    .Where("source.Name=connection.Source AND target.Type=connection.Target")

    Source Target 正确的方向?