#8546·elsa-core

Dapper DateTimeOffset type handler depends on provider initialization order

Author: sfmskywalkerCreated Sep 29, 2026Updated Sep 29, 2026

SqliteDbConnectionProvider and PostgreSqlDbConnectionProvider each register a process-wide Dapper DateTimeOffset handler from a static constructor (SqlMapper.AddTypeHandler), and the last registration wins:

  • the SQLite handler accepts only strings;
  • the PostgreSQL handler (TypeHandlers/PostgreSql/DateTimeOffsetHandler, ported from elsa-extensions#259 in #8545) accepts DateTime/DateTimeOffset.

When both providers are initialized in one process, and PostgreSQL goes first, a later PostgreSQL timestamp read throws InvalidCastException. Greptile reproduced both orders while reviewing #8545.

A production host uses one provider, so this mainly affects mixed-provider test runs and tools. The fix is a single handler that accepts both representations, or per-provider mapping instead of global registration, plus a test that initializes both providers in each order.

Source: elsa-workflows/elsa-core