I convert from SQL Server to PostgreSQL
I used ADO.NET
My queries include defined variables inside the query
For example this
SqlCommand sqlCommand=new SqlCommand(
@"declare @tempId bigint
select top 1 @tempId = col1 from table
if @tempId is not null
begin
select ...
end
else
begin
select ...
end ")
How do I do it with NpgsqlCommand?
IFcommand and Postgres has no extension to the SQL language to support that. You will have to do that conditional logic in Ado.net or write a stored procedure using PL/pgSQL where variables and conditional execution is supported.