Skip to content

Unhandled Exception: System.InvalidCastException: Unable to cast object of type 'System.DateTime' to type 'System.DateTimeOffset' #2820

Open
@amul047

Description

@amul047

Steps to replicate:

  • Use nhibernate with npgsql
  • Create an entity with a DateTimeOffset property
  • Create a PostgresQL database table with timestamptz column
  • Use appropriate column name mapping (we use FluentNHibernate for this)
  • Try to get the entity in a nhibernate session

What happens:
Throws Unhandled Exception: System.InvalidCastException: Unable to cast object of type 'System.DateTime' to type 'System.DateTimeOffset'

What should happen:
timestamptz column should map neatly to the DateTimeOffset property

Suggested solution:
Workaround from npgsql/npgsql#2641 (comment)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions