Skip to content

Instantly share code, notes, and snippets.

@dcomartin
Created May 11, 2023 17:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcomartin/d756490a5688904911d5f2f692f789a5 to your computer and use it in GitHub Desktop.
Save dcomartin/d756490a5688904911d5f2f692f789a5 to your computer and use it in GitHub Desktop.
public interface IRepository<T>
{
Task<T?> GetById<TId>(TId id, CancellationToken cancellationToken = default) where TId : notnull;
Task<T?> GetBySpec(ISpecification<T> specification, CancellationToken cancellationToken = default);
Task<List<T>> List(CancellationToken cancellationToken = default);
Task<List<T>> List(ISpecification<T> specification, CancellationToken cancellationToken = default);
Task<T> Add(T entity, CancellationToken cancellationToken = default);
Task<IEnumerable<T>> AddRange(IEnumerable<T> entities, CancellationToken cancellationToken = default);
Task Update(T entity, CancellationToken cancellationToken = default);
Task DeleteAsync(T entity, CancellationToken cancellationToken = default);
Task<int> SaveChangesAsync(CancellationToken cancellationToken = default);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment