neo4j - 我们可以创建具有相同关系类型但具有不同值的相同节点之间的多重关系吗?

时间:2017-06-28 02:15:52

标签: neo4j

我们正在努力实现类似的目标 - 但我只是在下面举一个例子:

  1. (A) - [r:ACT_IN {role:'main actor'}] - >(m:movie)
  2. (A) - [r:ACT_IN {role:'side actor'}] - >(m:movie)
  3. 是否可以创建此类方案?因为当我试图添加第二行时,它不会添加任何内容。

    谢谢, PK!

1 个答案:

答案 0 :(得分:3)

当然可以。您没有提供确切的Cypher查询,因此不清楚您哪里出错了。

但是,这是一个工作示例(假设数据库已经包含那些MovieMATCH (a:Actor {name: 'Keanu Reeves'}), (m:Movie {title: 'The Matrix'}) CREATE (a)-[r1:ACT_IN {role:'main actor'}]->(m), (a)-[r2:ACT_IN {role:'side actor'}]->(m); 个节点):

         var x = db.Campaigns.Where(w => w.ClientID == user.ClientID)
        .GroupJoin(db.Divisions, c => c.DivisionID, d => d.id, (c, d) => new { cmp = c, Division = d.FirstOrDefault().Name })
        .GroupJoin(db.Links, cdl => cdl.cmp.id, l => l.campaignID, (cdl, l) => new { cdl.cmp, cdl.Division, Links = l.Count() })
        .ToList()
        .Select(s => new
        {
            CampaignName = s.cmp.Name,
            Campaignid = s.cmp.id,
            Division = s.Division ?? "-",
            Created = s.cmp.created,
            Links = s.Links
        });