In some rare cases Dapper sends requests to SQLServer without parameters. I was able to reproduce it in test project:
https://github.com/dj-raphael/Dapper-test-lost-parameters
To reproduce, you should start this project in Visual Studio in Debug mode and wait for about a minute. However we encounter this problem from time to time (very rarely) in Release build on our production server. Here is the screenshot of exception we get:
https://github.com/dj-raphael/Dapper-test-lost-parameters/blob/master/exception.png
Here is the log obtained using MiniProfiler.Integrations library, I'm logging sql request before it was sent to SQLServer
try
{
...
var result = await connection.QueryAsync(sql.ToString(), map: Map, types: types, splitOn: splitOn, param: parameterValues).ConfigureAwait(false);
}
catch (SqlException e)
{
e.Data["profile-query-after-dapper"] = profiler.GetCommands();
e.AppendExceptionData(sql.ToString(), parameterValues);
throw;
}
https://github.com/dj-raphael/Dapper-test-lost-parameters/blob/master/example-log.txt
Log shows that I'm passing parameters to Dapper but SQLServer receives a request without any parameters at all. Another interesting fact is that it happens only when at least one of parameters is an array.
In some rare cases Dapper sends requests to SQLServer without parameters. I was able to reproduce it in test project:
https://github.com/dj-raphael/Dapper-test-lost-parameters
To reproduce, you should start this project in Visual Studio in Debug mode and wait for about a minute. However we encounter this problem from time to time (very rarely) in Release build on our production server. Here is the screenshot of exception we get:
https://github.com/dj-raphael/Dapper-test-lost-parameters/blob/master/exception.png
Here is the log obtained using MiniProfiler.Integrations library, I'm logging sql request before it was sent to SQLServer
https://github.com/dj-raphael/Dapper-test-lost-parameters/blob/master/example-log.txt
Log shows that I'm passing parameters to Dapper but SQLServer receives a request without any parameters at all. Another interesting fact is that it happens only when at least one of parameters is an array.