You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We encountered an issue retrieving DynamicParameters using the Get method after the QueryAsync method was finished.
The stored procedure always returns the parameters we are looking for. Most of the calls are working fine, but still, the issue appears for less than 1% of cases with the next call stack:
System.NullReferenceException: Object reference not set to an instance of an object.
at Dapper.DynamicParameters.Get[T](String name) in /_/Dapper/DynamicParameters.cs:line 329
This issue has been started right after moving from System.Data.SqlClient to Microsoft.Data.SqlClient
Code example:
using (var connection = new SqlConnection(_connectionString))
{
await _asyncRetryPolicy.ExecuteAsync(() => connection.OpenAsync());
DynamicParameters queryParameters = new DynamicParameters();
queryParameters.Add(name: ERROR_CODE_PARAMETER_NAME, value: null, dbType: DbType.Int32, direction: ParameterDirection.Output);
queryParameters.Add(name: ERROR_MESSAGE_PARAMETER_NAME, value: "Unknown error", dbType: DbType.AnsiString, direction: ParameterDirection.Output, size: ERROR_MESSAGE_LEN);
var result = await connection.QueryAsync<T>(storedProcedureName, queryParameters, commandType: CommandType.StoredProcedure, commandTimeout: commandTimeout);
int errorCode = queryParameters.Get<int>(ERROR_CODE_PARAMETER_NAME); // NullReference here
}
Could you please help us troubleshoot this issue?
Thank you.
We encountered an issue retrieving DynamicParameters using the Get method after the QueryAsync method was finished.
The stored procedure always returns the parameters we are looking for. Most of the calls are working fine, but still, the issue appears for less than 1% of cases with the next call stack:
This issue has been started right after moving from System.Data.SqlClient to Microsoft.Data.SqlClient
Code example:
Could you please help us troubleshoot this issue?
Thank you.
Additional context
Microsoft.Data.SqlClient v.5.2.0
Dapper v.2.0.123
The text was updated successfully, but these errors were encountered: