Dapper icon indicating copy to clipboard operation
Dapper copied to clipboard

Wrong GridIndex for Identity

Open Baldemaier opened this issue 3 years ago • 1 comments

I had a problem with QueryAsync (error sql parameter not found, but I use a dynamicparameter) and found out that the "Identity" default constructor use GridIndex with 0, but it should use -1 (for dynamic Parameters). Before calling QueryAsync I used QueryMultiple with the same sql statement and GridReader.ReadAsync cached the query with no parameters. So there was an error in QueryAsync that no parameters were passed to the SqlCommand.

Wrong: internal Identity(string sql, CommandType? commandType, IDbConnection connection, Type type, Type parametersType) : this(sql, commandType, connection.ConnectionString, type, parametersType, 0, 0) { /* base call */ }

Correct: internal Identity(string sql, CommandType? commandType, IDbConnection connection, Type type, Type parametersType) : this(sql, commandType, connection.ConnectionString, type, parametersType, 0, -1) { /* base call */ }

Baldemaier avatar Mar 24 '22 17:03 Baldemaier

Maybe the same as #1678

Baldemaier avatar Mar 25 '22 05:03 Baldemaier