I'm trying to bind an array of values to a IN clause in a PreparedStatement, but I'm not sure how.
This is a minimal example of what I'm trying to do:
private const string EXAMPLE_STATEMENT = "SELECT * FROM table WHERE owner = ? and bucket in (?)";
var _exampleStatement = new Lazy<Task<PreparedStatement>>(() => GetSession().PrepareAsync(EXAMPLE_STATEMENT));
var buckets = new List<double> { 4, 5, 6, 7 };
var result = await GetSession().ExecuteAsync(
(await _exampleStatement.Value).Bind(
"foo",
buckets
));
The equivalent in CQL would be:
SELECT * FROM table WHERE owner = 'foo' and bucket in (4, 5, 6, 7);
The binding of non-array parameters is working as intended.
I cannot use filtering (bucket >= 4 and bucket <= 7), as this field is part of the partition key.
There are likely 2 issues. First is that you don't need the parenthesis when preparing statement:
The second is that the CQL data type must match your C# data type when querying, i.e.
var buckets = new List<double> { 4, 5, 6, 7 };means that the bucket column must be of double type. Refer to the docs here for the type mapping between CQL and C#.