Open Genuineh opened 2 years ago
Hello, @Genuineh
The right side of IN
operator may be either a set of constant expressions or a table (see IN Operators for details).
You may modify your query and pass the array of values as a table with a single column:
using var cnn = new ClickHouseConnection(settings.ToString());
await cnn.OpenAsync().ConfigureAwait(false);
var cmd = cnn.CreateCommand("SELECT * FROM cktest WHERE id IN ids");
var ids = new long[] { 1, 2 };
var tableProvider = new ClickHouseTableProvider("ids", ids.Length);
tableProvider.AddColumn(ids);
cmd.TableProviders.Add(tableProvider);
var res = await cmd.ExecuteReaderAsync().ConfigureAwait(false);
Hi, @victor-sushko Thanks for your replay, it work right.
hi, @victor-sushko I got error when i want to use dapper style sql like "in @ids"
await cnn.QueryAsync<object>("SELECT * FROM cktest WHERE id IN @ids", new { ids = new[] { 1L, 2L } });
Octonica.ClickHouseClient.Exceptions.ClickHouseServerException : DB::Exception: Types of column 1 in section IN don't match: Int64 on the left, Array(Int64) on the right
Whether not support array parameters with dapper style
Code
Error