I'm trying to get strongly typed objects back out of Neo4j using the C# client. This all works until I add a DateTime
property.
I've successfully inserted data into the Neo4j database and I can see it using the console. I can also query the data, but I can't return any strongly typed objects because the deserialization seems to fail.
I'm using parameters to insert the data:
_graphClient.Cypher
.WithParams(new
{
id = node.Id,
createdAt = node.CreatedAt,
lastModified = node.LastModified
})
.Create("(c { " +
"Id: {id}, " +
"CreatedAt: {createdAt}, " +
"LastModified: {lastModified} } )")
My query to get the data is pretty basic:
nodes = _graphClient.Cypher
.Match("(n)")
.Return((n) => n.As<NeoObject>()).Results.ToList();
But then I receive an error...
The log file states the following:
Parameter name: content ---> Newtonsoft.Json.JsonReaderException: Could not convert string to DateTime: 17-9-2015 21:57:14 +00:00. Path 'a', line 1, position 32.
The data looks like this (entry from log):
"data" : {
"Id" : 31,
"LastModified" : "2015-09-17T21:57:14Z",
"CreatedAt" : "2015-09-17T21:57:14Z",
}
My c# type definitions:
public class NeoObject
{
public int Id { get; set; }
public DateTime CreatedAt { get; set; }
public DateTime LastModified { get; set; }
}
or
public class NeoObject2
{
public int Id { get; set; }
public DateTime? CreatedAt { get; set; }
public DateTime? LastModified { get; set; }
}