Skip to content

Instantly share code, notes, and snippets.

@dcomartin
Created Nov 17, 2021
Embed
What would you like to do?
public interface IAsyncRepository<T> where T : BaseEntity, IAggregateRoot
{
Task<T> GetByIdAsync(int id, CancellationToken cancellationToken = default);
Task<IReadOnlyList<T>> ListAllAsync(CancellationToken cancellationToken = default);
Task<IReadOnlyList<T>> ListAsync(ISpecification<T> spec, CancellationToken cancellationToken = default);
Task<T> AddAsync(T entity, CancellationToken cancellationToken = default);
Task UpdateAsync(T entity, CancellationToken cancellationToken = default);
Task DeleteAsync(T entity, CancellationToken cancellationToken = default);
Task<int> CountAsync(ISpecification<T> spec, CancellationToken cancellationToken = default);
Task<T> FirstAsync(ISpecification<T> spec, CancellationToken cancellationToken = default);
Task<T> FirstOrDefaultAsync(ISpecification<T> spec, CancellationToken cancellationToken = default);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment