0

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() );
Community
  • 1
  • 1
user2960136
  • 158
  • 7
  • 1
    Have you tried setting up the converter using default settings before creating the client? See [Registering a custom JsonConverter globally in Json.Net](http://stackoverflow.com/q/19510532/10263) – Brian Rogers May 15 '16 at 14:22
  • Thanks Brian, your clue led me to find the answer. I did not test just setting it globally as I discovered the right property of the neo4jClient to use. – user2960136 May 16 '16 at 11:40
  • Glad you got it figured out. You might consider posting an answer to your own question in case someone else runs into the same problem. – Brian Rogers May 16 '16 at 13:31

1 Answers1

1

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.

user2960136
  • 158
  • 7