我想使用Neo4jClient动态地添加Node的Lable和属性--我尝试像下面的代码那样来解决它,但是它不起作用。
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
发布于 2016-01-17 15:19:50
好的,首先,Neo4j默认不支持Dictionary元素(如Hashtable),因此您将需要一个自定义序列化程序,如以下问题中的一个:Can Neo4j store a dictionary in a node?
知道了这一点,您就不能以您正在尝试的方式设置Properties Hashtable中的值。这不可能。
现在,我们来看看Cypher。
所以,赛弗-我不能百分之百确定你想要做什么,但我认为这是你想要的:
var data = new Data{Type="Vegetable"};
data.Properties.Add("name", "zhai");
client.Cypher
.Create("(person {personParam})")
.WithParam("personParam", data)
.ExecuteWithoutResults();这将将节点放入数据库,但是您将无法通过Properties属性中的任何值进行查询。
我认为你应该花点时间去阅读“密码手册”来了解你想要做的事情,因为我认为这会让你得到更多的帮助。
https://stackoverflow.com/questions/34807995
复制相似问题