user2960136
user2960136

Reputation: 158

Cannot deserialize datetime property Neo4j using C# client in a transaction

My problem is related to this question:

I'm having the same failure, but in a different scenario:

At run time the error is occurring inside;

using (var scope = new TransactionScope())
{
    // Doing stuff here fails only within a transaction!
    scope.Complete();
}

The same problem code runs perfectly fine when executed outside of a transaction!

The error message is:

Newtonsoft.Json.JsonReaderException was unhandled
HResult=-2146233088 LineNumber=1 LinePosition=33 Message=Could not convert string to DateTime: 15/05/2016 09:23:34 +00:00. Path 'a', line 1, position 33. Path=a Source=Neo4jClient

The code versions are:

Neo4jClient version=1.1.0.16 Newtonsoft.Json version=8.0.1

This answer basically says I can pass a

new IsoDateTimeConverter { DateTimeFormat = "dd/MM/yyyy" }

To the serialisation but as that is inside Neo4jClient how can I implement that.

Answer

client.JsonConverters.Add( new IsoDateTimeConverter() );

Upvotes: 0

Views: 218

Answers (1)

user2960136
user2960136

Reputation: 158

Adding this line of code immediately after creating the client, solved the of datetime serialisation problem.

Note: my culture is en-GB so I am not sure if this would need finegling to adjust for your culture settings.

client.JsonConverters.Add( new IsoDateTimeConverter() );

I think there are numerous ways of making this happen but this one definately works.

Upvotes: 1

Related Questions