Brenton
Brenton

Reputation: 124

Datetime in the Relationship payload isn't deserialized correctly

Background.

I'm storing User and Product nodes and I want to be able to record a date for each time that user purchases a product. When the results are being return the Purchased date is coming back as DateTime.Min but if I query Neo4j through the console I can see the dates are being stored as "2013-02-16T08:31:54.8604715+00:00"

The query I'm using to return the relationship payload is:

graphClient
.RootNode
.In < RootNode >(sourceTypeKeyToRoot)
.OutE<TData>(TypeKeyRelatingNodes())
.ToList();

TData is a simple class

public class PayLoad
{
   public DateTime Purchased { get; set; }
}

I get the same result if I use the Cypher queries as well.

Upvotes: 1

Views: 265

Answers (1)

Tatham Oddie
Tatham Oddie

Reputation: 4290

This is not a supported type, because we can't roundtrip it via Neo4j properly.

You should use DateTimeOffset instead.

You should receive an exception if you try to use DateTime, for any builds since 1.0.0.174 or so:

http://hg.readify.net/neo4jclient/src/d4118523780ee5dcacbe2f57b4f40ee6b90d6500/Neo4jClient/Deserializer/CommonDeserializerMethods.cs?at=default#cl-109

http://hg.readify.net/neo4jclient/commits/fa5bedfa60cb

Upvotes: 1

Related Questions