diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/BasicRepositoryBase.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/BasicRepositoryBase.cs index 1235dc37141..4be7954a355 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/BasicRepositoryBase.cs +++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/BasicRepositoryBase.cs @@ -55,7 +55,7 @@ protected virtual Task SaveChangesAsync(CancellationToken cancellationToken) { if (UnitOfWorkManager?.Current != null) { - return UnitOfWorkManager?.Current.SaveChangesAsync(cancellationToken); + return UnitOfWorkManager.Current.SaveChangesAsync(cancellationToken); } return Task.CompletedTask; @@ -63,8 +63,34 @@ protected virtual Task SaveChangesAsync(CancellationToken cancellationToken) public abstract Task UpdateAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default); + public virtual async Task UpdateManyAsync(IEnumerable entities, bool autoSave = false, CancellationToken cancellationToken = default) + { + foreach (var entity in entities) + { + await UpdateAsync(entity, cancellationToken: cancellationToken); + } + + if (autoSave) + { + await SaveChangesAsync(cancellationToken); + } + } + public abstract Task DeleteAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default); + public virtual async Task DeleteManyAsync(IEnumerable entities, bool autoSave = false, CancellationToken cancellationToken = default) + { + foreach (var entity in entities) + { + await DeleteAsync(entity, cancellationToken: cancellationToken); + } + + if (autoSave) + { + await SaveChangesAsync(cancellationToken); + } + } + public abstract Task> GetListAsync(bool includeDetails = false, CancellationToken cancellationToken = default); public abstract Task GetCountAsync(CancellationToken cancellationToken = default);