I am using Npgsql to issue parameterized PostGIS queries on a Postgres database. The problem is that Npgsql casts all parameterized variables using a longhand notation, and PostGIS doesn't understand cast variables in some cases.
For example, suppose the original query starts with this:
ST_GeometryFromText('POLYGON((:x :y,...
Npgsql turns it into this:
ST_GeometryFromText('POLYGON((((1278594)::int4) ((1206979)::int4),...
That doesn't work. It would work if the casts could be left out, like this:
ST_GeometryFromText('POLYGON((1278594 1206979,...
There is apparently a UseCast
attribute of a parameter, but it is not settable per NpgsqlParameter.cs.
Do I have any alternative besides dynamically constructing my queries?