我使用的是Neo4J 2.2.2。
当Neo4jClient尝试反序列化以下json(模式投影)时,我们收到以下消息:
Neo4j返回了有效的响应,但Neo4jClient无法反序列化为您提供的对象结构。 首先,尝试并查看下面的例外情况,找出问题所在。 包括此异常的全文,包括此消息,堆栈跟踪和所有内部异常详细信息。 包括VB $ AnonymousType_0`2 [[Person,App_Code.tynn6afz,Version = 0.0.0.0,Culture = neutral,PublicKeyToken = null],[Movie,App_Code.tynn6afz,Version = 0.0.0.0,Culture = neutral]的完整类型定义,PublicKeyToken = null]]。
包含此原始JSON,其中任何敏感值都替换为非敏感值:
{
"columns": [
"person",
"movie"
],
"data": [
[
{
"outgoing_relationships": "http://sjkdv37:7474/db/data/node/324/relationships/out",
"labels": "http://sjkdv37:7474/db/data/node/324/labels",
"data": {
"born": 1956,
"name": "Tom Hanks"
},
"all_typed_relationships": "http://sjkdv37:7474/db/data/node/324/relationships/all/{-list|&|types}",
"traverse": "http://sjkdv37:7474/db/data/node/324/traverse/{returnType}",
"self": "http://sjkdv37:7474/db/data/node/324",
"property": "http://sjkdv37:7474/db/data/node/324/properties/{key}",
"properties": "http://sjkdv37:7474/db/data/node/324/properties",
"outgoing_typed_relationships": "http://sjkdv37:7474/db/data/node/324/relationships/out/{-list|&|types}",
"incoming_relationships": "http://sjkdv37:7474/db/data/node/324/relationships/in",
"extensions": {},
"create_relationship": "http://sjkdv37:7474/db/data/node/324/relationships",
"paged_traverse": "http://sjkdv37:7474/db/data/node/324/paged/traverse/{returnType}{?pageSize,leaseTime}",
"all_relationships": "http://sjkdv37:7474/db/data/node/324/relationships/all",
"incoming_typed_relationships": "http://sjkdv37:7474/db/data/node/324/relationships/in/{-list|&|types}",
"metadata": {
"id": 324,
"labels": [
"Person"
]
}
},
{
"outgoing_relationships": "http://sjkdv37:7474/db/data/node/364/relationships/out",
"labels": "http://sjkdv37:7474/db/data/node/364/labels",
"data": {
"released": 2006,
"title": "The Da Vinci Code",
"tagline": "Break The Codes"
},
"all_typed_relationships": "http://sjkdv37:7474/db/data/node/364/relationships/all/{-list|&|types}",
"traverse": "http://sjkdv37:7474/db/data/node/364/traverse/{returnType}",
"self": "http://sjkdv37:7474/db/data/node/364",
"property": "http://sjkdv37:7474/db/data/node/364/properties/{key}",
"properties": "http://sjkdv37:7474/db/data/node/364/properties",
"outgoing_typed_relationships": "http://sjkdv37:7474/db/data/node/364/relationships/out/{-list|&|types}",
"incoming_relationships": "http://sjkdv37:7474/db/data/node/364/relationships/in",
"extensions": {},
"create_relationship": "http://sjkdv37:7474/db/data/node/364/relationships",
"paged_traverse": "http://sjkdv37:7474/db/data/node/364/paged/traverse/{returnType}{?pageSize,leaseTime}",
"all_relationships": "http://sjkdv37:7474/db/data/node/364/relationships/all",
"incoming_typed_relationships": "http://sjkdv37:7474/db/data/node/364/relationships/in/{-list|&|types}",
"metadata": {
"id": 364,
"labels": [
"Movie"
]
}
}
],
[
{
"outgoing_relationships": "http://sjkdv37:7474/db/data/node/324/relationships/out",
"labels": "http://sjkdv37:7474/db/data/node/324/labels",
"data": {
"born": 1956,
"name": "Tom Hanks"
},
"all_typed_relationships": "http://sjkdv37:7474/db/data/node/324/relationships/all/{-list|&|types}",
"traverse": "http://sjkdv37:7474/db/data/node/324/traverse/{returnType}",
"self": "http://sjkdv37:7474/db/data/node/324",
"property": "http://sjkdv37:7474/db/data/node/324/properties/{key}",
"properties": "http://sjkdv37:7474/db/data/node/324/properties",
"outgoing_typed_relationships": "http://sjkdv37:7474/db/data/node/324/relationships/out/{-list|&|types}",
"incoming_relationships": "http://sjkdv37:7474/db/data/node/324/relationships/in",
"extensions": {},
"create_relationship": "http://sjkdv37:7474/db/data/node/324/relationships",
"paged_traverse": "http://sjkdv37:7474/db/data/node/324/paged/traverse/{returnType}{?pageSize,leaseTime}",
"all_relationships": "http://sjkdv37:7474/db/data/node/324/relationships/all",
"incoming_typed_relationships": "http://sjkdv37:7474/db/data/node/324/relationships/in/{-list|&|types}",
"metadata": {
"id": 324,
"labels": [
"Person"
]
}
},
{
"outgoing_relationships": "http://sjkdv37:7474/db/data/node/414/relationships/out",
"labels": "http://sjkdv37:7474/db/data/node/414/labels",
"data": {
"released": 2004,
"title": "The Polar Express",
"tagline": "This Holiday Season… Believe"
},
"all_typed_relationships": "http://sjkdv37:7474/db/data/node/414/relationships/all/{-list|&|types}",
"traverse": "http://sjkdv37:7474/db/data/node/414/traverse/{returnType}",
"self": "http://sjkdv37:7474/db/data/node/414",
"property": "http://sjkdv37:7474/db/data/node/414/properties/{key}",
"properties": "http://sjkdv37:7474/db/data/node/414/properties",
"outgoing_typed_relationships": "http://sjkdv37:7474/db/data/node/414/relationships/out/{-list|&|types}",
"incoming_relationships": "http://sjkdv37:7474/db/data/node/414/relationships/in",
"extensions": {},
"create_relationship": "http://sjkdv37:7474/db/data/node/414/relationships",
"paged_traverse": "http://sjkdv37:7474/db/data/node/414/paged/traverse/{returnType}{?pageSize,leaseTime}",
"all_relationships": "http://sjkdv37:7474/db/data/node/414/relationships/all",
"incoming_typed_relationships": "http://sjkdv37:7474/db/data/node/414/relationships/in/{-list|&|types}",
"metadata": {
"id": 414,
"labels": [
"Movie"
]
}
}
]
]
}
修改
我包含VB代码,但我认为这个错误是由Neo4jClient生成的。
可能错误在CypherJsonDeserializer.cs的ParseInProjectionMode函数周围
Dim user As String = "neo4j"
Dim pwd As String = "password"
Dim server As String = "localhost:7474"
Dim link As String = "http://{0}:{1}@{2}/db/data"
Dim url As New Uri(String.Format(link, user, pwd, server))
Dim client As New GraphClient(url)
client.Connect()
Dim query = client.Cypher _
.Match("(p:Person {name: ""Tom Hanks""})-[:ACTED_IN]->(m:Movie)") _
.Return(Function(p, m) New With {
.person = p.As(Of Person)(), _
.movie = m.As(Of Movie)()
})
'Here the client threw an Exception
For Each item In query.Results
Dim temp As String = String.Format("{0} - {1}<br>", item.movie.title, item.movie.released)
divOut.InnerHtml += temp
Next
另外,我创建了这些类。
Public Class Movie
Public Property title As String
Public Property released As Integer
Public Property tagline As String
End Class
Public Class Person
Public Property name As String
Public Property born As Integer
End Class
答案 0 :(得分:1)
错误源于您正在创建的匿名类型,现在,我不假装知道原因,并且不花一些时间挖掘Neo4jClient
代码库 - 很难找到究竟。
你可以通过使用具体类来解决这个问题,这个例子可以工作并将数据输出到屏幕上(我想指出,我是没有 vb编码器,所以借口愚蠢的错误):
Module Module1
Private Class Together
Public Property Person As Person
Public Property Movie As Movie
End Class
Sub Main()
Dim user = "neo4j"
Dim pwd = "password"
Dim server = "localhost:7474"
Dim link = "http://{0}:{1}@{2}/db/data"
Dim url As New Uri(String.Format(link, user, pwd, server))
Dim client As New GraphClient(url)
client.Connect()
Dim query = New CypherFluentQuery(client) _
.Match("(p:Person {name: ""Tom Hanks""})-[:ACTED_IN]->(m:Movie)") _
.Return(Function(p, m) New Together With {
.Person = p.As(Of Person)(), _
.Movie = m.As(Of Movie)()
})
Dim results = query.Results.ToList()
For Each item In results
Dim temp As String = String.Format("{0} - {1}<br>", item.Movie.title, item.Movie.released)
Console.WriteLine(temp)
Next
Console.ReadLine()
End Sub
End Module
定义您已经拥有它们的类。
您可以尝试在Neo4jClient
代码库中修复此问题并发出拉取请求(这会很好),如果您真的需要这个,那么您可能希望获得代码和使用你自己编译的版本而不是nuget,因为活动开发似乎暂停了一个小咒语。
PS。 特定于vb,C#非常满意这种匿名类型,所以也许某种方式在VB中处理匿名类型,这在代码库中是无法识别的。