StevenRasmussen / EFCore.SqlServer.NodaTime

NodaTime support for EF Core
MIT License
105 stars 18 forks source link

Any plans to support ZonedDateTime? #22

Open HerrNiklasRaab opened 3 years ago

HerrNiklasRaab commented 3 years ago

https://nodatime.org/3.0.x/userguide/zoneddatetime-patterns

StevenRasmussen commented 3 years ago

There are not any plans currently to support the ZonedDateTime type. Based on the documentation I think we could serialize/deserialize the value in string format but it would be very difficult (if even possible) to support any operators/methods for this type. Are you just envisioning being able to store a value for this type in the DB but NOT perform any operations against it?

anthonylevine commented 2 years ago

Hi @StevenRasmussen ,

Just getting my bearings with Noda Time and had the same question about ZonedDateTime. Can I ask why it would be difficult to store in SQL Server? I'm still trying to understand the concepts in Noda Time. Would it be because technically you'd need 2 columns (one for the date/time) and another for the timezone? Thanks again for the package. It's been a lifesaver.

StevenRasmussen commented 2 years ago

@anthonylevine - Right... the issue is that there's no native SQL type that can store all the information for the ZonedDateTime NodaTime type. We could put it in a string in SQL, or split it up as you mention, but it becomes extremely difficult (if not impossible) to support any operations against this type in TSQL. We could serialize/deserialize to/from this from a C# perspective but we would be unable to support any operations against it like:

var orders = context.Orders.Where(x => x.ZonedDateTime >= someArbitraryZonedDateTime);

The best we could do is storage and retrieval of the information. Any operations would need to be performed client side. Hopefully that makes sense.

anthonylevine commented 2 years ago

Thank you so much for the detailed reply and totally makes sense. And thanks again for the library.