Skip to content

Feature Request: Deletion of entities via specification #363

@thorstenalpers

Description

@thorstenalpers

Hi, Ardalis Specification is a really great project that I use extensively as Nuget. I have an additional feature request. I have implemented in my own EfRepository, but would like to see in your project. It is about deleting entities per specification.

The existing way is to list entities and then delete them.

 public abstract class RepositoryBase<T> : IReadRepository<T> where T : class
{
...
   public virtual async Task DeleteRangeAsync(ISpecification<T> specification, CancellationToken cancellationToken = default)
    {
        var query = ApplySpecification(specification);
        _dbContext.Set<T>().RemoveRange(query);
        await SaveChangesAsync(cancellationToken);
    }
...
}

I could also create a PR with unittests.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions