when I run my SQL query directly I have to issues:
SELECT [hostname]
FROM [ComputerImport]
where LOWER(SUBSTRING (computerimport.hostname, 1, 2)) in ('DE', 'FR') AND computerimport.hostname LIKE '%'
but when I try to do it out of c# I get no results
string searchString = ""
List<string> allowedStatus = new List<string>();
allowedStatus.Add("de");
string sqlquery = "SELECT computerimport.hostname FROM ComputerImport WHERE LOWER(SUBSTRING (computerimport.hostname, 1, 2)) in ({1}) AND (computerimport.hostname LIKE '%' + {0} + '%') ";
_context.OverviewQueries.FromSqlRaw(sqlquery, searchString, string.Join(",", allowedStatus.Select(s => "'" + s + "'").ToArray()));
I also tried:
string.Join(",", allowedStatus.Select(s => "'" + s + "'")
string.Join(",", allowedStatus)
string.Join(",", allowedStatus)ToArray()
What works is:
_context.OverviewQueries.FromSqlRaw(sqlquery, searchString, "DE");
Any idea what I am missing?