[英]How to add properties of node dynamically using Neo4jClient?
我想使用Neo4jClient动态添加Lable和Node的属性,我尝试像下面的代码一样解决它,但是它不起作用。
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; }
}
}
我想将数据的属性导入节点的属性。 汤姆·汤姆
好的,首先, Neo4j
默认情况下不支持Dictionary
元素(如Hashtable
),因此您将需要一个自定义的序列化程序,例如该问题中的一个: Neo4j可以在节点中存储字典吗?
知道这一点后,您将无法按照尝试的方式在“ Properties
Hashtable
”中设置值。 这是不可能的。
因此,现在已经不成问题了,让我们看一下Cypher
。
因此,在密码方面明智-我不是100%知道您要做什么, 但是我认为您追求的是这样的事情:
var data = new Data{Type="Vegetable"};
data.Properties.Add("name", "zhai");
client.Cypher
.Create("(person {personParam})")
.WithParam("personParam", data)
.ExecuteWithoutResults();
这样会将节点放入数据库中, 但是您将无法通过Properties
属性中的任何值进行查询。
我认为您应该花一些时间阅读Cypher手册,以了解您要执行的操作,因为我认为这将使您更进一步。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.