What is the correct syntax for varname to make this query work? I can get it to work with a single variable like
string varname = "TOTAL_NORWAY"
However, if I want to have a few variables in there, I get an empty array returned:
string varname = "'TOTAL_NORWAY', 'TOTAL_SWEDEN'";
return await _Context.theDataModel.FromSqlRaw(@"
select data
from data_table
where Variable in ({0})
", varname).ToListAsync();
select data from data_table where Variable in ('''TOTAL_NORWAY'', ''TOTAL_SWEDEN''')... google for"ef core" where in arraystring varname = "'TOTAL_NORWAY', 'TOTAL_SWEDEN'";is a single string, not two values. Parameters are that - parameters to a function, not string substitution placeholders. That's why they protect from SQL injection attacks. Whatever is in those parameters is never included in the query itself, it's sent as separate parameters to the RPC call to the server