DapperLib / Dapper

Dapper - a simple object mapper for .Net
https://www.learndapper.com/
Other
17.29k stars 3.67k forks source link

Missing signature on QueryAsync method #2094

Open FabienEstier opened 3 weeks ago

FabienEstier commented 3 weeks ago

I'm using this method signature for QueryAsync: public static Task 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 ?

konstantinLyang commented 2 weeks ago

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?

richardcox13 commented 2 weeks ago

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

konstantinLyang commented 2 weeks ago

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???