Dapper icon indicating copy to clipboard operation
Dapper copied to clipboard

Missing signature on QueryAsync method

Open FabienEstier opened this issue 1 year ago • 3 comments

I'm using this method signature for QueryAsync: public static Task<IEnumerable> QueryAsync(this IDbConnection cnn, string sql, Type[] types, Func<object[], TReturn> map, object? param = null, IDbTransaction? transaction = null, bool buffered = true, string splitOn = "Id", int? commandTimeout = null, CommandType? commandType = null)

I need to pass a Cancellation token but there is no available signature with Type[] types, Func<object[], TReturn> map and string splitOn parameters. I tried to used the signature with a CommandDefinition object because it contains a property named CancellationToken but this signature doesn't contain types, map and splitOn too. Is it possible to add it in a future release ?

FabienEstier avatar Jun 13 '24 23:06 FabienEstier

I searched the entire Internet and found no information about this.. What should I do with complex queries? Does it turn out that developers using dapper have to turn a blind eye to security and speed? If the user clicks 10,000 times in a row on the button to receive data from the api and it is the QueryAsync method that is complex and WITHOUT a cancellation token, what happens then?

konstantinLyang avatar Jun 19 '24 09:06 konstantinLyang

Use a QueryAsync definition that takes a CommandDefinition, pass your CancellationToken to the CommandDefinition constructor.

richardcox13 avatar Jun 19 '24 10:06 richardcox13

Use a QueryAsync definition that takes a CommandDefinition, pass your CancellationToken to the CommandDefinition constructor.

for simple tasks. If we need insert mapper, types, split on parameters???

konstantinLyang avatar Jun 20 '24 02:06 konstantinLyang