Does anyone have any suggestions as to why the variable works returns 743 rows, but the variable notworks returns none?
As far as I can see they are doing the same thing.
I cannot publish the stored procedure, but I don't think that is the issue here as I am able to get a result set from the first variable.
I tried using a SQL trace - which I am new to - and could not see anything that helped me solve this.
var TretSpefParameter = new SqlParameter("TretSpef", "101");
var SexParameter = new SqlParameter("Sex", 1);
var SDiagParameter = new SqlParameter("SDiag", "*");
var works = await Context.Database.SqlQuery<sp_RefData_Predictive>("sp_RefData_Predictive @TretSpef = '101', @Sex = 1, @SDiag = '*'").ToListAsync();
var notWorks = await Context.Database.SqlQuery<sp_RefData_Predictive>("sp_RefData_Predictive @TretSpef, @Sex, @SDiag", TretSpefParameter, SexParameter, SDiagParameter).ToListAsync();
sp_prefix for your stored procedures. Microsoft has reserved that prefix for its own use (see Naming Stored Procedures), and you do run the risk of a name clash sometime in the future. It's also bad for your stored procedure performance. It's best to just simply avoidsp_and use something else as a prefix - or no prefix at all!