Skip to content

Dapper looses parameters #1169

Description

@dj-raphael

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions