我想在我的neo4jclient c#应用程序中使用merge,所以我读了this link并创建了如下所示的查询:
resultList.ForEach(
tweets => client.Cypher
.Merge("(tweet:Tweet {newtweet})")
.OnCreate()
.Set("tweet = {newtweet}")
.WithParams(new Tweets(tweets))
.ExecuteWithoutResults());
但它崩溃了,我不知道我错过了什么。
我的代码中哪一部分错了?
答案 0 :(得分:2)
首先定义你的推文类:
public class Tweet {
public long StatusId { get; set; }
public string Author { get; set; }
public string Content { get; set; }
}
然后尝试这样的声明:
var newTweet = new Tweet { StatusId = 2344
, Author = "@AuthorName"
, Content = "this is a tweet" };
graphClient.Cypher
.Merge("(tweet:Tweet { StatusId: {id} })")
.OnCreate()
.Set("tweet = {newTweet}")
.WithParams(new {
id = newTweet.StatusId,
newTweet
})
.ExecuteWithoutResults();