Per Francisco Figueiredo Jr. and Josh Cooley, two key developers of Npgsql, there is currently no good way to force Npgsql not to cast parameterized values.
While it is possible to set the parameter to type DbType.Object
, which may avoid casting, that has issues with ambiguous function calls and possibly inducing bugs.
For values that need to go inside WKT, I am using a workaround of string replacement on the query before parameters are processed.