Skip to content

Commit

Permalink
#343 CancellationToken Support for BaseRepository
Browse files Browse the repository at this point in the history
  • Loading branch information
mikependon committed Oct 2, 2020
1 parent 0874a2e commit e8ad995
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions RepoDb.Core/RepoDb/BaseRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using RepoDb.Enumerations;
using System;
using System.Dynamic;
using System.Threading;

namespace RepoDb
{
Expand Down Expand Up @@ -345,6 +346,7 @@ public IEnumerable<TEntity> ExecuteQuery(string commandText,
/// </param>
/// <param name="cacheItemExpiration">The expiration in minutes of the cache item.</param>
/// <param name="transaction">The transaction to be used.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> object to be used during the asynchronous operation.</param>
/// <returns>
/// An enumerable list of data entity objects containing the converted results of the underlying <see cref="IDataReader"/> object.
/// </returns>
Expand All @@ -353,14 +355,16 @@ public Task<IEnumerable<TEntity>> 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<TEntity>(commandText: commandText,
param: param,
commandType: commandType,
cacheKey: cacheKey,
cacheItemExpiration: cacheItemExpiration,
transaction: transaction);
transaction: transaction,
cancellationToken: cancellationToken);
}

#endregion
Expand Down Expand Up @@ -405,16 +409,19 @@ public int ExecuteNonQuery(string commandText,
/// </param>
/// <param name="commandType">The command type to be used.</param>
/// <param name="transaction">The transaction to be used.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> object to be used during the asynchronous operation.</param>
/// <returns>The number of rows affected by the execution.</returns>
public Task<int> 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
Expand Down Expand Up @@ -459,16 +466,19 @@ public object ExecuteScalar(string commandText,
/// </param>
/// <param name="commandType">The command type to be used.</param>
/// <param name="transaction">The transaction to be used.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> object to be used during the asynchronous operation.</param>
/// <returns>An object that holds the first occurence value (first column of first row) of the execution.</returns>
public Task<object> 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
Expand Down Expand Up @@ -515,16 +525,19 @@ public TResult ExecuteScalar<TResult>(string commandText,
/// </param>
/// <param name="commandType">The command type to be used.</param>
/// <param name="transaction">The transaction to be used.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> object to be used during the asynchronous operation.</param>
/// <returns>A first occurence value (first column of first row) of the execution.</returns>
public Task<TResult> ExecuteScalarAsync<TResult>(string commandText,
object param = null,
CommandType? commandType = null,
IDbTransaction transaction = null)
IDbTransaction transaction = null,
CancellationToken cancellationToken = default)
{
return DbRepository.ExecuteScalarAsync<TResult>(commandText: commandText,
param: param,
commandType: commandType,
transaction: transaction);
transaction: transaction,
cancellationToken: cancellationToken);
}

#endregion
Expand Down

0 comments on commit e8ad995

Please sign in to comment.