I have this SQL query (in T-SQL):
--DECLARE @strTerm varchar(300)
--SET @strTerm = 'c'
SELECT TOP 10
USR_ID
,USR_UserName
FROM T_Benutzer
WHERE (1=1)
--AND {fn LCASE(USR_UserName)} LIKE {fn LCASE(@strTerm + '%')}
AND {fn LCASE(BE_User)} LIKE {fn LCASE({fn CONCAT(@strTerm, '%')} )}
--AND BE_Hide = 0
AND BE_Hide = 'false'
ORDER BY USR_UserName
Then, I have an automagic regex transform which I can switch on, to make the top syntax compatible with PostgreSQL, which generates the following output statement from the input statement:
SELECT
USR_ID
,USR_UserName
FROM T_Benutzer
WHERE (1=1)
AND {fn LCASE(BE_User)} LIKE {fn LCASE({fn CONCAT(@strTerm, '%')} )}
AND BE_Hide = 'false'
ORDER BY USR_UserName
LIMIT 10
I thought this should suffice to get most things working on PostgreSQL, but now I realize that Npgsql doesn’t recognize ODBC escape sequences ({fn whatever()}).
Is there any option in the Npgsql connectionstring settings that I can turn on, or in Postgres itself?
Or am I out of luck, and have to write an ODBC escape functions replace function?
The PostgreSQL server itself does not have any escape syntax for functions like that. The whole purpose of this escape syntax is to abstract several DB dialects. Moving exactly this into a specific server would be dubious at best.
The Npgsql manual does not mention any escape processing nor connection string parameters for that purpose.
So you are out of luck.