尝试使用Neo4jClient,获得此异常,说它无法处理来自Neo4j的其他有效响应:
{"Neo4j returned a valid response, however Neo4jClient was unable to deserialize into the object structure you supplied.
First, try and review the exception below to work out what broke.
If it's not obvious, you can ask for help at http://stackoverflow.com/questions/tagged/neo4jclient
Include the full text of this exception, including this message, the stack trace, and all of the inner exception details.
Include the full type definition of MyStory.Logic.DbUpdateSlice.Model.DbUpdate.
Include this raw JSON, with any sensitive values replaced with non-sensitive equivalents:
{
\"columns\" : [ \"dbUpdates\" ],
\"data\" : [ [ {
\"outgoing_relationships\" : \"http://127.255.0.0:20001/db/data/node/853098/relationships/out\",
\"data\" : {
\"UpdateStart\" : \"2014-10-24T15:30:23\",
\"UpdateMethodName\" : \"abc.def\",
\"DbUpdateState\" : \"Running\",
\"UniqueId\" : 1
},
\"traverse\" : \"http://127.255.0.0:20001/db/data/node/853098/traverse/{returnType}\",
\"all_typed_relationships\" : \"http://127.255.0.0:20001/db/data/node/853098/relationships/all/{-list|&|types}\",
\"property\" : \"http://127.255.0.0:20001/db/data/node/853098/properties/{key}\",
\"self\" : \"http://127.255.0.0:20001/db/data/node/853098\",
\"properties\" : \"http://127.255.0.0:20001/db/data/node/853098/properties\",
\"outgoing_typed_relationships\" : \"http://127.255.0.0:20001/db/data/node/853098/relationships/out/{-list|&|types}\",
\"incoming_relationships\" : \"http://127.255.0.0:20001/db/data/node/853098/relationships/in\",
\"extensions\" : {
},
\"create_relationship\" : \"http://127.255.0.0:20001/db/data/node/853098/relationships\",
\"paged_traverse\" : \"http://127.255.0.0:20001/db/data/node/853098/paged/traverse/{returnType}{?pageSize,leaseTime}\",
\"all_relationships\" : \"http://127.255.0.0:20001/db/data/node/853098/relationships/all\",
\"incoming_typed_relationships\" : \"http://127.255.0.0:20001/db/data/node/853098/relationships/in/{-list|&|types}\"
} ], [ {
\"outgoing_relationships\" : \"http://127.255.0.0:20001/db/data/node/853099/relationships/out\",
\"data\" : {
\"UpdateStart\" : \"2014-11-04T01:32:23\",
\"UpdateMethodName\" : \"xyz.123.987\",
\"DbUpdateState\" : \"Failed\",
\"UniqueId\" : 2
},
\"traverse\" : \"http://127.255.0.0:20001/db/data/node/853099/traverse/{returnType}\",
\"all_typed_relationships\" : \"http://127.255.0.0:20001/db/data/node/853099/relationships/all/{-list|&|types}\",
\"property\" : \"http://127.255.0.0:20001/db/data/node/853099/properties/{key}\",
\"self\" : \"http://127.255.0.0:20001/db/data/node/853099\",
\"properties\" : \"http://127.255.0.0:20001/db/data/node/853099/properties\",
\"outgoing_typed_relationships\" : \"http://127.255.0.0:20001/db/data/node/853099/relationships/out/{-list|&|types}\",
\"incoming_relationships\" : \"http://127.255.0.0:20001/db/data/node/853099/relationships/in\",
\"extensions\" : {
},
\"create_relationship\" : \"http://127.255.0.0:20001/db/data/node/853099/relationships\",
\"paged_traverse\" : \"http://127.255.0.0:20001/db/data/node/853099/paged/traverse/{returnType}{?pageSize,leaseTime}\",
\"all_relationships\" : \"http://127.255.0.0:20001/db/data/node/853099/relationships/all\",
\"incoming_typed_relationships\" : \"http://127.255.0.0:20001/db/data/node/853099/relationships/in/{-list|&|types}\"
} ] ]
}
Parameter name: content"}
DbUpdate的定义
public class DbUpdate
{
public long UniqueId { get; set; }
public string UpdateMethodName { get; set; }
public DateTime? UpdateStart { get; set; }
public DateTime? UpdateEnd { get; set; }
public DbUpdateState DbUpdateState { get; set; }
}
实际测试代码:
var dbUpdate1 = new DbUpdate()
{
UpdateMethodName = "abc.def",
UpdateStart = new DateTime(2014, 10, 24, 15, 30, 23),
UpdateEnd = null,
DbUpdateState = DbUpdateState.Running
};
long dbUpdate1UniqueId = dbUpdateRepository.CreateDbUpdate(dbUpdate1);
var dbUpdates = dbUpdateRepository.GetAllDbUpdates().ToList();
<<<<<此方法中抛出的异常。见下文。
包含从测试代码调用的方法的repo类:
public class DbUpdateRepository: IDbUpdateRepository
{
readonly IGraphClient graphClient;
readonly IMyStoryUserPrincipal principal;
readonly IMyStoryUniqueIdGenerator uniqueIdGenerator;
public DbUpdateRepository (
IMyStoryUserPrincipal principal,
IGraphClient graphClient,
IMyStoryUniqueIdGenerator uniqueIdGenerator)
{
this.principal = principal;
this.graphClient = graphClient;
this.uniqueIdGenerator = uniqueIdGenerator;
}
public IEnumerable<DbUpdate> GetAllDbUpdates ()
{
var query = graphClient
.RootNode
.StartCypher("root")
.Match("root-[:" + HasDbUpdates.TypeKey + "]-dbUpdates")
.Return(dbUpdates => dbUpdates.As<DbUpdate>());
return query.Results; <<<<< exception thrown here
}
public long CreateDbUpdate (DbUpdate dbUpdate)
{
dbUpdate.UniqueId = uniqueIdGenerator.NextDbUpdateId();
graphClient.Create(dbUpdate,
new HasDbUpdates(graphClient.RootNode)
{
Direction = RelationshipDirection.Incoming
});
return dbUpdate.UniqueId;
}
}
答案 0 :(得分:1)
原来Neo4jClient无法处理DateTime。您必须使用DateTimeOffset。