I have strange error while I am trying to view results of SqlQuery:
var sql = "SELECT @someParam";
var someParamSqlParameter = new SqlParameter("someParam", "Some Value");
var result = _dbContext.SqlQuery<string>(sql, someParamSqlParameter);
var containsAnyElements = result.Any();
So when debugger is at last line and when I try to expand Results View of result it shows me expected result("Some Value")
but on invoking last line I got an exception
"The SqlParameter is already contained by another SqlParameterCollection.".
It looks like when I try to open Result View of result it invokes this query again. If that behavior correct? If yes, please explain why that happens.
See Question&Answers more detail:os