我想使用Npgsql 3.1.7进行PostgreSQL查询:
SELECT jdoc FROM myTable where jdoc -> 'tags' @> '[{"name": "tv"}]'
代码如下所示:
using (var dbConnection = new NpgsqlConnection("myconnection")) {
dbConnection.Open();
var request = dbConnection.ExecuteReader("SELECT jdoc FROM myTable where jdoc -> 'tags' @> '[{\"name\": @var1}]'"),
new { var1 = "tv" });
}
jsonb运算符@>
被视为参数,我得到了这个例外:
{"22P02: invalid input syntax for type json"}
Token "@" is invalid.
有没有办法将此运算符与转义机制一起使用?