I'am using .net core. I have following entity, where EndDate could be null:
public class MyEntity
{
public Guid Id { get; set; }
public DateTime StartDate { get; set; }
public DateTime? EndDate { get; set; }
}
My table:
create table MyEntity(
id uuid not null,
start_date timestamp not null,
end_date timestamp
constraint MyEntity_pkc primary key (id)
);
I have following merge statement:
merge into MyEntity c
using (values (@Id, @StartDate, @EndDate)) v
on c.id = v.column1
when not matched then
insert (id, start_date, end_date)
values (v.column1, v.column2, v.column3)
when matched then
update set start_date = v.column2, end_date = v.column3
I execute merge, where entity.EndDate == null:
await connection.ExecuteAsync(sqlTemplate.Get("MergeMyEntity"), entity);
I've got error:
Npgsql.PostgresException (0x80004005): 42804: column "end_date" is of type timestamp without time zone but expression is of type text
How should I insert null for EndDate?