Closed DanieleSky closed 3 years ago
The underlying methods of Dapper which Dommel uses do not allow to pass a cancellation token. Therefore there is no point in Dommel adding them to its methods.
Hi @henkmollema, I found that with CommandDefinitions you can pass a cancellation token. This is the reference https://stackoverflow.com/a/25545312/4189041
I tried this method and works.
For example, I think that the method GetAllAsync could become:
public static Task> GetAllAsync(this IDbConnection connection, IDbTransaction? transaction = null, CancellationTokenSource? tokenSource = null) where TEntity : class
{
var sql = BuildGetAllQuery(connection, typeof(TEntity));
LogQuery(sql);
return connection.QueryAsync(new CommandDefinition(sql, transaction: transaction, cancellationToken: tokenSource.Token));
}
What do you think?
Hi @henkmollema , any news about my last comment? Thank you
Hi, I'm using your extension with Dapper and I would to know how I can cancel an expensive query with async methods (ex GetAllAsync). I see that all Async method don't have the CancellationToken parameter.
How I can do this?
Thanks