【问题标题】:How to create nodes with multiple labels into neo4j with c#如何使用 c# 在 neo4j 中创建具有多个标签的节点
【发布时间】:2019-12-13 12:44:37
【问题描述】:

我是 neo4j 的新手,想尝试在 c# 中创建一个设置。 我一直在尝试创建一个具有多个标签的节点,稍后我将能够连接这些标签。

我尝试了不同的方法,但都失败了。

var newUser = new CreateNode { Id = 2, Name = "Test" };
var test1 = new Movie { Title = "The Matrix" };
client.Cypher
    .Create("(user:CreateNode {newUser})")
    .WithParam("newUser", newUser)
    .ExecuteWithoutResults();

public class CreateNode
{
    [JsonProperty(PropertyName = "id")]
    public long Id { get; set; }

    [JsonProperty(PropertyName = "name")]
    public string Name { get; set; }

    [JsonProperty("movie")]
    public Movie Movie { get; set; }
}

这适用于具有一个标签的节点,但如果我尝试向节点添加电影标签,我似乎无法找到解决方法。

如果我做对了,标签就在那里,所以我可以在节点之间创建特定的 RL。如果存在标签为young的用户,例如连接带有标签动画的节点电影。

【问题讨论】:

    标签: c# graph neo4j


    【解决方案1】:

    要创建具有多个标签的节点,只需用更多冒号分隔您想要的标签。例如:

    client.Cypher
        .Create("(user:User:Young:Student {newUser})")
        .WithParam("newUser", newUser)
        .ExecuteWithoutResults();
    

    【讨论】:

      猜你喜欢
      • 2022-12-30
      • 2014-04-15
      • 1970-01-01
      • 2020-03-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多