serilog-sinks-mssqlserver icon indicating copy to clipboard operation
serilog-sinks-mssqlserver copied to clipboard

Fix UTC handling for TimeStamp column with ConvertToUtc=true

Open marcominerva opened this issue 1 week ago • 0 comments

This pull request addresses a bug related to timestamp handling in the MSSqlServer sink, ensuring that timestamps are correctly converted to UTC when the ConvertToUtc option is set. It also adds a corresponding unit test to verify this behavior.

Bugfix: Timestamp UTC conversion

  • Updated GetTimeStampStandardColumnNameAndValue in StandardColumnDataGenerator.cs to use UtcDateTime for the timestamp value when ConvertToUtc is enabled, ensuring correct UTC storage.

Testing improvements

  • Added a unit test GetStandardColumnNameAndValueForTimeStampCreatesUtcDateTimeUsingUtcDateTimeProperty in StandardColumnDataGeneratorTests.cs to verify that the timestamp is converted to UTC and stored as a DateTime with DateTimeKind.Utc when ConvertToUtc is set.

Closes #659

marcominerva avatar Dec 12 '25 09:12 marcominerva