I have int list and I need to convert it so it will be possible to send it to IN operator from c# code. I tried a lot of manipulate but got error every time.
string idsList = "(" + string.Join(",", ids.Select(id => $"'{id.ToString()}'")) +")";
var sql = @"SELECT * from user
WHERE user.id IN (@idsList))";
using (var connection = OpenConnection())
{
var results = await connection.QueryAsync<UserQueryResponse>(sql, new
{
idsList= idsList,
});
return results.Select(raw =>raw.CreateModel());
}
}
The column type of user.id is string