jonwagner / Insight.Database

Fast, lightweight .NET micro-ORM

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How can I select a DateTime as UTC - not as kind "Unspecified"?

elandev opened this issue · comments

Describe the question

I am inserting a row into the database where the DateTime property value is in UTC.

When I query the data back from the database it is not returned as UTC, but as the kind "Unspecified".

This causes other issues when doing datetime and interval comparisons. Thus, I have to manually convert the datetimes from the database to UTC, before doing any such comparisons.

Is there a way, possibly through a property attribute, to indicate that the DateTime should be of the kind UTC?

Steps to reproduce

  1. Load the attached project with Visual Studio 2022.
  2. Set up MariaDB as the database (10.11.2-MariaDB).
  3. Edit the server, database name and credentials for the connection string.
  4. Restore Nuget packages and build the solution.
  5. Run the project.

Look at the console output and you will see:

DateTime Inserted: 2023-03-25 17:38:26Z Kind=Utc
DateTime Returned: 2023-03-25 17:38:26Z Kind=Unspecified
DateTime Returned: 2023-03-25 17:38:26Z Kind=Unspecified
  • Dotnet version: 6.0
  • Database: 10.11.2-MariaDB
  • Library version: Insight 6.3.11

TestMySqlDateTime.zip

commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Is there a solution to this?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Unfortunately, we can't accept project zip files as reproduction cases. Please paste sufficient code to reproduce here, or submit a PR with a failing test case.