henkmollema / Dommel

CRUD operations with Dapper made simple.
MIT License
634 stars 100 forks source link

Column Date in Postgres #285

Closed fernandocristan closed 1 year ago

fernandocristan commented 2 years ago

In my table I have a Date column and the property on the entity is DateTime. I am not able to insert this column in dotnet 6, the following error occurs:

'Cannot write DateTime with Kind=Unspecified to PostgreSQL type 'timestamp with time zone', only UTC is supported'

Apparently the parameter is being sent as datetime (info).

What can I do to adjust this?

I also use the package Dapper.FluentMap.Dommel

henkmollema commented 1 year ago

I think this issue is not part of Dommel, it just forwards the parameters to Dapper. Perhaps you can use the suggestion of roji as a starting point:

Otherwise you can explicitly set NpgsqlDbType on the parameter to NpgsqlDbType.Date (see Dapper custom parameter types).