Reputation: 14866
I am trying to add parameterised query using tsquery for postrgresql.
The raw postgresql looks like:
and search @@ 'john' ::tsquery;
Any time I try to add it to a query like:
query.And("search @@ 'john' ::tsquery");
It throws error that it is potentially unsafe fragment.
How do I allow this to pass validation?
Upvotes: 1
Views: 68
Reputation: 143319
Use C# string.Format syntax for indexing db params in SQL Fragment queries, e.g:
query.And("search @@ {0}::tsquery;", request.SearchTerm);
You can use UnsafeAnd
to bypass SQL Fragment validation
Upvotes: 2