Hello.
Let’s say I have a query like this:
select m.body.*
from `mybucket` m
use keys ['doc::1001', 'doc::2001', 'doc::3001', 'doc::4001', 'doc::5001', 'doc::6001', 'doc::7001', 'doc::8001', 'doc::9001']
Question 1:
With C# SDK, when constructing prepared statement for the above query using QueryRequest, I could not figure out how to pass array of keys as positional parameters.
This does not work:
string q = "select m.body.* from `mybucket` m use keys $1";
string[] keys = {"doc::1001", "doc::2001", "doc::3001", "doc::4001", "doc::5001", "doc::6001", "doc::7001", "doc::8001", "doc::9001"};
IQueryRequest query = new QueryRequest().Statement(q).AdHoc(false);
query.AddPositionalParameter(keys);
My work-around is like this:
string q = "select m.body.* from `mybucket` m use keys [";
string[] keys = {"doc::1001", "doc::2001", "doc::3001", "doc::4001", "doc::5001", "doc::6001", "doc::7001", "doc::8001", "doc::9001"};
for (int i = 1; i < keys.Length; i++) {
q += $"${i}";
}
q += "]"; // close the square bracket
IQueryRequest query = new QueryRequest().Statement(q).AdHoc(false);
foreach (var k in keys) {
query.AddPositionalParameter(k);
}
// query execution code here...
What am I missing?
Question #2:
The number of keys can vary from one to a few hundreds. Given this fact, is it even beneficial to use prepared statement for this query?
Thanks in advance for your answer.