Skip to content

Commit

Permalink
#343 CancellationToken Support for the Delete Operation.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikependon committed Sep 28, 2020
1 parent 285df5e commit a7e9a73
Show file tree
Hide file tree
Showing 3 changed files with 172 additions and 67 deletions.
50 changes: 36 additions & 14 deletions RepoDb.Core/RepoDb/Operations/BaseRepository/Delete.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Data;
using System.Linq.Expressions;
using System.Threading;
using System.Threading.Tasks;

namespace RepoDb
Expand Down Expand Up @@ -136,14 +137,17 @@ public int Delete(QueryGroup where,
/// <param name="entity">The data entity object to be deleted.</param>
/// <param name="hints">The table hints 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 that has been deleted from the table.</returns>
public Task<int> DeleteAsync(TEntity entity,
string hints = null,
IDbTransaction transaction = null)
IDbTransaction transaction = null,
CancellationToken cancellationToken = default)
{
return DbRepository.DeleteAsync<TEntity>(entity: entity,
hints: hints,
transaction: transaction);
transaction: transaction,
cancellationToken: cancellationToken);
}

/// <summary>
Expand All @@ -153,14 +157,17 @@ public Task<int> DeleteAsync(TEntity entity,
/// <param name="what">The dynamic expression or the key value to be used.</param>
/// <param name="hints">The table hints 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 that has been deleted from the table.</returns>
public Task<int> DeleteAsync<TWhat>(TWhat what,
string hints = null,
IDbTransaction transaction = null)
IDbTransaction transaction = null,
CancellationToken cancellationToken = default)
{
return DbRepository.DeleteAsync<TEntity, TWhat>(what: what,
hints: hints,
transaction: transaction);
transaction: transaction,
cancellationToken: cancellationToken);
}

/// <summary>
Expand All @@ -169,14 +176,17 @@ public Task<int> DeleteAsync<TWhat>(TWhat what,
/// <param name="what">The dynamic expression or the key value to be used.</param>
/// <param name="hints">The table hints 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 that has been deleted from the table.</returns>
public Task<int> DeleteAsync(object what,
string hints = null,
IDbTransaction transaction = null)
IDbTransaction transaction = null,
CancellationToken cancellationToken = default)
{
return DbRepository.DeleteAsync<TEntity>(what: what,
hints: hints,
transaction: transaction);
transaction: transaction,
cancellationToken: cancellationToken);
}

/// <summary>
Expand All @@ -185,14 +195,17 @@ public Task<int> DeleteAsync(object what,
/// <param name="where">The query expression to be used.</param>
/// <param name="hints">The table hints 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 that has been deleted from the table.</returns>
public Task<int> DeleteAsync(Expression<Func<TEntity, bool>> where,
string hints = null,
IDbTransaction transaction = null)
IDbTransaction transaction = null,
CancellationToken cancellationToken = default)
{
return DbRepository.DeleteAsync<TEntity>(where: where,
hints: hints,
transaction: transaction);
transaction: transaction,
cancellationToken: cancellationToken);
}

/// <summary>
Expand All @@ -201,14 +214,17 @@ public Task<int> DeleteAsync(Expression<Func<TEntity, bool>> where,
/// <param name="where">The query expression to be used.</param>
/// <param name="hints">The table hints 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 that has been deleted from the table.</returns>
public Task<int> DeleteAsync(QueryField where,
string hints = null,
IDbTransaction transaction = null)
IDbTransaction transaction = null,
CancellationToken cancellationToken = default)
{
return DbRepository.DeleteAsync<TEntity>(where: where,
hints: hints,
transaction: transaction);
transaction: transaction,
cancellationToken: cancellationToken);
}

/// <summary>
Expand All @@ -217,14 +233,17 @@ public Task<int> DeleteAsync(QueryField where,
/// <param name="where">The query expression to be used.</param>
/// <param name="hints">The table hints 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 that has been deleted from the table.</returns>
public Task<int> DeleteAsync(IEnumerable<QueryField> where,
string hints = null,
IDbTransaction transaction = null)
IDbTransaction transaction = null,
CancellationToken cancellationToken = default)
{
return DbRepository.DeleteAsync<TEntity>(where: where,
hints: hints,
transaction: transaction);
transaction: transaction,
cancellationToken: cancellationToken);
}

/// <summary>
Expand All @@ -233,14 +252,17 @@ public Task<int> DeleteAsync(IEnumerable<QueryField> where,
/// <param name="where">The query expression to be used.</param>
/// <param name="hints">The table hints 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 that has been deleted from the table.</returns>
public Task<int> DeleteAsync(QueryGroup where,
string hints = null,
IDbTransaction transaction = null)
IDbTransaction transaction = null,
CancellationToken cancellationToken = default)
{
return DbRepository.DeleteAsync<TEntity>(where: where,
hints: hints,
transaction: transaction);
transaction: transaction,
cancellationToken: cancellationToken);
}

#endregion
Expand Down
Loading

0 comments on commit a7e9a73

Please sign in to comment.