C# 如何使用Neo4jClient动态添加节点的属性?
我想使用Neo4jClient动态添加节点的标签和属性 我试图像下面的代码一样解决它,但它不起作用C# 如何使用Neo4jClient动态添加节点的属性?,c#,neo4j,neo4jclient,C#,Neo4j,Neo4jclient,我想使用Neo4jClient动态添加节点的标签和属性 我试图像下面的代码一样解决它,但它不起作用 client.Cypher .Create("(person:Type)") .WithParam("Type", "Vegetable") .Set("person.property= \"zhai\"") .WithParam("propert
client.Cypher
.Create("(person:Type)")
.WithParam("Type", "Vegetable")
.Set("person.property= \"zhai\"")
.WithParam("property", "name")
.ExecuteWithoutResults();
我的模型是
class Data
{
public Data()
{
properties = new Hashtable();
}
private string type;
public string Type
{
get { return type; }
set { type = value; }
}
private Hashtable properties;
public Hashtable Properties
{
get { return properties; }
set { properties = value; }
}
}
我想将数据的属性导入节点的属性。
Thx Z.Tom好的,首先,
Neo4j
默认情况下不支持字典
元素(如哈希表
),因此您需要一个自定义序列化程序,如本问题中的序列化程序:
知道了这一点,您就无法按您尝试的方式设置属性哈希表中的值。这是不可能的
现在,让我们来看看Cypher
所以,塞弗-我不是100%确定你想做什么,但我想这就是你想要的:
var data = new Data{Type="Vegetable"};
data.Properties.Add("name", "zhai");
client.Cypher
.Create("(person {personParam})")
.WithParam("personParam", data)
.ExecuteWithoutResults();
这将把节点放入数据库,但是您将无法通过属性中的任何值进行查询
我认为您应该花一点时间阅读Cypher手册,以了解您正在尝试做什么,因为我认为这会让您走得更远。好的,首先,Neo4j
默认情况下不支持字典
元素(如哈希表
),因此您需要一个自定义序列化程序,例如这个问题中的一个:
知道了这一点,您就无法按您尝试的方式设置属性哈希表中的值。这是不可能的
现在,让我们来看看Cypher
所以,塞弗-我不是100%确定你想做什么,但我想这就是你想要的:
var data = new Data{Type="Vegetable"};
data.Properties.Add("name", "zhai");
client.Cypher
.Create("(person {personParam})")
.WithParam("personParam", data)
.ExecuteWithoutResults();
这将把节点放入数据库,但是您将无法通过属性中的任何值进行查询
我认为你应该花一点时间阅读密码手册,了解你想做什么,因为我认为这会让你走得更远。谢谢,克里斯~,它非常有用谢谢,克里斯~,它非常有用