I am trying to migrate Couchbase SDK from 2.7 to 3.1, I use the IQueryRequest to pass all the queries information, and AddNamedParameter for all parameters when using QueryAsync , is there a way to do this in 3.1.
I checked the migration guide Migrating from SDK2 to SDK3 API | Couchbase Docs however it doesn’t specify anything about how to migrate those QueryRequests, it looks like QueryAsync only accepts a string.
Am I missing something?
Thanks,
Cluster.QueryAsync
has a second parameter for options and you would use the QueryOptions.Parameter
method for your parameters:
var options = new QueryOptions().
Parameter("bucket","default").
Parameter("name","bill");
var result = await cluster.QueryAsync("SELECT * FROM `$bucket` WHERE name=$name", options);
If your using positional parameters you use the overload the just takes the value.
Jeff
1 Like
Thank you Jeff!
Yeah, that means that I will need to convert all the QueryRequests to strings and send the parameters as QueryOptions, so the QueryAsync can execute what I need.
1 Like