DotNet4Neo4j / Neo4jClient

.NET client binding for Neo4j
https://www.nuget.org/packages/Neo4jClient
Microsoft Public License
431 stars 146 forks source link

DateTime deserialized as null or default when using version >= 5 #464

Open cmaart opened 1 year ago

cmaart commented 1 year ago

Describe the bug Neo4j Driver seems to return DateTime as lazy-ZonedDateTime which is not deserialized as DateTime.

Seems to happen only when using return as anonymous object not when returning types directly. Works: Return.As<Model>("n") DateTime properties are null Return(() => new { MyModel = Return.As<Model>("n")})

Usage: image

Deserialization in Neo4jClient shows Json contains lazy-ZonedDateTime image

Downgrading to the latest 4.x version fixes the issue.

Versions:

thelonelyvulpes commented 1 year ago

Hi @cmaart This is because of a change that was implemented in the dotnet driver. At the very latest, this will be fixed in 5.11.

awatertrevi commented 1 year ago

Issue still persists in 5.11.

thelonelyvulpes commented 1 year ago

@awatertrevi The driver was changed removing lazy parsing of ZonedDateTimes, but instead it can return something such as: "{ UtcSeconds: 1000, Nanoseconds: 0, Zone: "Antartica/Troll" }" this is because in order to convert the ZonedDateTime to the local date & time values the driver needs to be able to look up the offset from UTC, but if the zone is unknown to the OS it will fail. The reason the driver does not throw is because zones that might not be legal on one machine may be legal on the neo4j server.

If you have further details or recreation scenarios that don't match this case, please let me know.