Skip to content

Commit

Permalink
Add Bulk Operation method to IBasicRepository
Browse files Browse the repository at this point in the history
- Related with #6654
  • Loading branch information
enisn committed Dec 15, 2020
1 parent 6a3e229 commit 4e4b245
Showing 1 changed file with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ public interface IBasicRepository<TEntity> : IReadOnlyBasicRepository<TEntity>
[NotNull]
Task<TEntity> InsertAsync([NotNull] TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default);

/// <summary>
/// Inserts multiple new entities.
/// </summary>
/// <param name="autoSave">
/// Set true to automatically save changes to database.
/// This is useful for ORMs / database APIs those only save changes with an explicit method call, but you need to immediately save changes to the database.
/// </param>
/// <param name="cancellationToken">A <see cref="T:System.Threading.CancellationToken" /> to observe while waiting for the task to complete.</param>
/// <param name="entities">Entities to be inserted.</param>
/// <returns>Awaitable <see cref="Task"/>.</returns>
Task InsertManyAsync([NotNull] IEnumerable<TEntity> entities, bool autoSave = false, CancellationToken cancellationToken = default);

/// <summary>
Expand All @@ -35,6 +45,17 @@ public interface IBasicRepository<TEntity> : IReadOnlyBasicRepository<TEntity>
[NotNull]
Task<TEntity> UpdateAsync([NotNull] TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default);

/// <summary>
/// Updates multiple entities.
/// </summary>
/// <param name="entities">Entities to be updated.</param>
/// <param name="autoSave">
/// Set true to automatically save changes to database.
/// This is useful for ORMs / database APIs those only save changes with an explicit method call, but you need to immediately save changes to the database.</param>
/// <param name="cancellationToken">A <see cref="T:System.Threading.CancellationToken" /> to observe while waiting for the task to complete.</param>
/// <returns>Awaitable <see cref="Task"/>.</returns>

Task UpdateManyAsync(IEnumerable<TEntity> entities, bool autoSave = false, CancellationToken cancellationToken = default);
/// <summary>
/// Deletes an entity.
/// </summary>
Expand All @@ -45,6 +66,18 @@ public interface IBasicRepository<TEntity> : IReadOnlyBasicRepository<TEntity>
/// </param>
/// <param name="cancellationToken">A <see cref="T:System.Threading.CancellationToken" /> to observe while waiting for the task to complete.</param>
Task DeleteAsync([NotNull] TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default);

/// <summary>
/// Deletes multiple entities.
/// </summary>
/// <param name="entities">Entities to be deleted.</param>
/// <param name="autoSave">
/// Set true to automatically save changes to database.
/// This is useful for ORMs / database APIs those only save changes with an explicit method call, but you need to immediately save changes to the database.
/// </param>
/// <param name="cancellationToken">A <see cref="T:System.Threading.CancellationToken" /> to observe while waiting for the task to complete.</param>
/// <returns>Awaitable <see cref="Task"/>.</returns>
Task DeleteManyAsync([NotNull] IEnumerable<TEntity> entities, bool autoSave = false, CancellationToken cancellationToken = default);
}

public interface IBasicRepository<TEntity, TKey> : IBasicRepository<TEntity>, IReadOnlyBasicRepository<TEntity, TKey>
Expand Down

0 comments on commit 4e4b245

Please sign in to comment.