简体   繁体   中英

EF Core Oracle Timestamp with Timezone to DateTime in c#

With EF Core 2.2.6 I am saving DateTime --> Oracle Timestamp(7) with Time zone : 30.07.19 18:13:23,283000000 +02:00 . But when I am reading it back its : 30.07.19 20:13:23,283000000 +02:00 .

How can I exlpicitly mention in EF core no DateTime convertions?

Dealing with DateTimes and Timezones is between complicated and able to drive you mad . However I have 3 rules that make working with them manageable:

  1. Always store and retrieve the UTC value
  2. Avoid storing or transmission as string
  3. If you can not follow rule 2 (like with XML), at least pick a fixed enconding and culture to use on every endpoint. You really do not want to add those to your worries.

However there are some scenarios (like a Calendar) where you have to deal with timezones instead.

Also note that 0.07.19 18:13:23,283000000 +02:00 is not actually the value. This is a String Representation of the value, using the users settings for details like formating and timezone.

Solved the issue. Changed the driver from Devart to Oracle.EntityFrameworkCore 2.19.30

1) Devart driver got some issues with Timezone offset. reading with timstamp + offset and writing to DB with out offset.

2) Oracle.EntityFrameworkCore 2.19.30 released a week back is the perfect solution for me. It solved 1) Timezone issue and 2) performance issue (10X faster). 3) some other small issues in my web application.

Thank you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM