SqlKata query takes each individual element of the collection as an additional parameter

294 Views Asked by At

I'm trying to pass multiple ids to postgres function.

Test(new[] { 1, 2 });

static void Test(IEnumerable<int> ids)
{
    var db = new QueryFactory(new SqlConnection(""), new SqlServerCompiler());

    var query = db.Query("").FromRaw($"Test.Test(?)", ids);

    var compiler = new SqlServerCompiler();
    SqlResult result = compiler.Compile(query);
    string sql = result.Sql; // SELECT * FROM Test.Test(@p0,@p1)
}

Instead of 1 parameter (IEnumerable<int>) query creates 2 (@p0,@p1).

Why is this happening and how to fix it?

0

There are 0 best solutions below