【发布时间】:2016-02-21 01:25:45
【问题描述】:
我是 Neo4j 场景的新手,但在尝试创建播放列表和歌曲之间的关系时,我收到以下 C# 错误:
An unhandled exception of type 'System.NullReferenceException' occurred in Neo4jClient.dll
Additional information: Object reference not set to an instance of an object.
C#代码:
client.Cypher
.Match("(song1:Song)", "(playlist1:Playlist)")
.Where((Song song1) => song1.Name == newSong.Name)
.AndWhere((Playlist playlist1) => playlist1.Name == newPlaylist.Name)
.Create("(playlist1)-[r:CONTAINS_SONG]->(song1)")
.ExecuteWithoutResults();
对象newSong 和newPlaylist 使用来自文件的数据作为种子,并且已经存在于Neo4j 数据库中。使用实时调试器时,我看到newSong.Name 等于“Goodbye In Her Eyes”,newPlaylist.Name 等于“Adam Country”。这些值都存在于 Neo4j 数据库中(如下)。使用 .Query.QueryText 也会产生相同的错误。我正在使用neo4j-community-3.0.0-M03 和Neo4jClient 1.1.0.28。
我创建了自己的有效查询,但我觉得 C# 代码与正在输出的实际查询之间存在脱节。以下作品:
MATCH (song1:Song),(playlist1:Playlist)
WHERE song1.Name = 'Goodbye In Her Eyes' AND playlist1.Name = 'Adam Country'
CREATE (playlist1)-[r:CONTAINS_SONG]->(song1)
Neo4j 浏览器文本输出:
+==============================+
|n |
+==============================+
|FullName: Adam Country.txt |
|Name: Adam Country |
+------------------------------+
|Artist: Zac Brown Band |
|FullName: Goodbye In Her Eyes |
|Name: Goodbye In Her Eyes |
+------------------------------+
我的 C# 代码应该是什么样子才能完成这种关系?
[Playlist "Adam Country"] CONTAINS_SONG [Song "Goodbye In Her Eyes"]
【问题讨论】:
-
你初始化客户端了吗?
-
您的
C#代码对我来说看起来不错,我已经直接使用它并通过 LinqPad 针对2.3x和3.0x数据库实例运行它,在这两种情况下都没有问题。能否请您展示您的Song和Playlist课程?
标签: c# graph neo4j neo4jclient nosql