From e8ad995c9fcbbbd57822b0aaa229c01fbc3c6d8e Mon Sep 17 00:00:00 2001 From: Michael Pendon Date: Fri, 2 Oct 2020 17:08:18 +0200 Subject: [PATCH] #343 CancellationToken Support for BaseRepository --- RepoDb.Core/RepoDb/BaseRepository.cs | 29 ++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/RepoDb.Core/RepoDb/BaseRepository.cs b/RepoDb.Core/RepoDb/BaseRepository.cs index 89612e22c..4f82f7571 100644 --- a/RepoDb.Core/RepoDb/BaseRepository.cs +++ b/RepoDb.Core/RepoDb/BaseRepository.cs @@ -6,6 +6,7 @@ using RepoDb.Enumerations; using System; using System.Dynamic; +using System.Threading; namespace RepoDb { @@ -345,6 +346,7 @@ public IEnumerable ExecuteQuery(string commandText, /// /// The expiration in minutes of the cache item. /// The transaction to be used. + /// The object to be used during the asynchronous operation. /// /// An enumerable list of data entity objects containing the converted results of the underlying object. /// @@ -353,14 +355,16 @@ public Task> ExecuteQueryAsync(string commandText, CommandType? commandType = null, string cacheKey = null, int? cacheItemExpiration = Constant.DefaultCacheItemExpirationInMinutes, - IDbTransaction transaction = null) + IDbTransaction transaction = null, + CancellationToken cancellationToken = default) { return DbRepository.ExecuteQueryAsync(commandText: commandText, param: param, commandType: commandType, cacheKey: cacheKey, cacheItemExpiration: cacheItemExpiration, - transaction: transaction); + transaction: transaction, + cancellationToken: cancellationToken); } #endregion @@ -405,16 +409,19 @@ public int ExecuteNonQuery(string commandText, /// /// The command type to be used. /// The transaction to be used. + /// The object to be used during the asynchronous operation. /// The number of rows affected by the execution. public Task ExecuteNonQueryAsync(string commandText, object param = null, CommandType? commandType = null, - IDbTransaction transaction = null) + IDbTransaction transaction = null, + CancellationToken cancellationToken = default) { return DbRepository.ExecuteNonQueryAsync(commandText: commandText, param: param, commandType: commandType, - transaction: transaction); + transaction: transaction, + cancellationToken: cancellationToken); } #endregion @@ -459,16 +466,19 @@ public object ExecuteScalar(string commandText, /// /// The command type to be used. /// The transaction to be used. + /// The object to be used during the asynchronous operation. /// An object that holds the first occurence value (first column of first row) of the execution. public Task ExecuteScalarAsync(string commandText, object param = null, CommandType? commandType = null, - IDbTransaction transaction = null) + IDbTransaction transaction = null, + CancellationToken cancellationToken = default) { return DbRepository.ExecuteScalarAsync(commandText: commandText, param: param, commandType: commandType, - transaction: transaction); + transaction: transaction, + cancellationToken: cancellationToken); } #endregion @@ -515,16 +525,19 @@ public TResult ExecuteScalar(string commandText, /// /// The command type to be used. /// The transaction to be used. + /// The object to be used during the asynchronous operation. /// A first occurence value (first column of first row) of the execution. public Task ExecuteScalarAsync(string commandText, object param = null, CommandType? commandType = null, - IDbTransaction transaction = null) + IDbTransaction transaction = null, + CancellationToken cancellationToken = default) { return DbRepository.ExecuteScalarAsync(commandText: commandText, param: param, commandType: commandType, - transaction: transaction); + transaction: transaction, + cancellationToken: cancellationToken); } #endregion