try
{
return Connection.QuerySingleOrDefault<T>(sql, param, _transaction,
commandType: CommandType.StoredProcedure);
}
catch (Exception orig)
{
var ex = new Exception($"Dapper proc execution failed!", orig);
AddDetailsToException(ex, sql, param);
throw ex;
}
With SQL:
CREATE OR REPLACE PROCEDURE public."GetChildBank"(
"bankId" integer DEFAULT NULL::integer)
LANGUAGE 'sql'
AS $BODY$
)
select * from cte where ParentBank is not null
and "Id" <> "bankId"
$BODY$;
I am using Dapper with PostgreSQL and using stored procedure to get data but it always throws errors.
It converts into a SQL statement
SELECT *
FROM "GetChildBank"("bankId" := $1)
which is wrong.
paramlook like here; and presumablysqlis the name of a stored procedure, in which case: what parameters are defined on it?orig.Messagesays. Any additional details would also be useful, butorig.Messageis the absolute minimum I need to stand a chance here (in a perfect world:orig.GetType().Namewould be nice, too, as would some info about whatsqlandparamare - maybe something about whatTis too)It converts into sql a statement SELECT * FROM "GetChildBank"("bankId" := $1) which is wrong- no, that's simply not a thing that dapper does, at all. It doesn't convert anything into anything. So; let's take a step back: what issqlhere? presumablysqlis"GetChildBank"? and presumablyparamlooks something likenew { bankId = 130134 }? Now: what actually happens? What isorig.Message?