Reputation: 5384
From NuGet, I am using
...\packages\Npgsql.2.2.5\lib\net45\Npgsql.dll
...\packages\Dapper.1.42\lib\net45\Dapper.dll
In calling a stored procedure in PostgreSQL, I have need to preserve the case of the procedure name as
var x = cnn.Query<icd9>("GetDxLibrary", commandType: CommandType.StoredProcedure);
I am getting a runtime error:
An unhandled exception of type 'Npgsql.NpgsqlException' occurred in Npgsql.dll
Additional information: ERROR: 42883: function getdxlibrary() does not exist.
If the function in PostgreSQL is renamed to getdxlibrary()
, all goes well.
How can I call a procedure with a mixed-case name in Dapper?
TIA
Upvotes: 1
Views: 639
Reputation: 16692
Just add quotes around your function name:
var x = cnn.Query<icd9>("\"GetDxLibrary\"", commandType: CommandType.StoredProcedure);
PostgreSQL automatically lower-cases all non-quoted identifiers, so when you send it GetDxLibrary it actually sees getdxlibrary.
Upvotes: 5