DateTimeOffset.Date does not correctly truncate time in dotConnect for PostgreSQL
Hello,
I am working on upgrading my company's application, based on dotConnect for PostgreSQL, from EF6 to EF Core. We have been using multiple methods from the DbFunctions class, many of which were removed in EF Core.
From my understanding, DateTimeOffset.Date should be used instead of DbFunction.TruncateTime():
https://stackoverflow.com/a/40760245. This does not work in dotConnect and I get a DateTime value with a time portion still present (but different from the one that was stored in the database). Npgsql correctly truncates the time portion.
I am running the code on my local machine with an offset of +2 (CEST), while the database is running inside the docker container with an offset of 0 (UTC). I have not tested this in a configuration where both database and code are running on machines with the same timezone.
When calling DateTimeOffset.Date in this configuration, the Hour is set to 1 instead of the expected 0. This surprised me, since the difference between the timezones of local machine and database is 2 hours. I suspect the one hour difference comes from the fact that the main timezone for my machine is CET with an offset of +1, however that timezone is in effect only in winter. The current summer timezone has an offset of +2.
Used versions:
.NET 8
Microsoft.EntityFrameworkCore.* 8.0.8
Devart.Data.PostgreSql.EFCore 8.3.21.8
I have attached a solution with test cases reproducing this issue and showing that npgsql works as expected.
Best regards,
Jan