Skip to content

Instantly share code, notes, and snippets.

@mattpodwysocki
Created January 30, 2018 15:58
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 mattpodwysocki/ec438ce2c5c5f545bf7f562d7670b973 to your computer and use it in GitHub Desktop.
Save mattpodwysocki/ec438ce2c5c5f545bf7f562d7670b973 to your computer and use it in GitHub Desktop.
public interface IDataRepository<TEntity> : IDisposable where TEntity : class
{
ICollection<TEntity> Find(
Expression<Func<TEntity, bool>> criteria,
Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> orderBy = null,
string includeProperties = "");
Task<ICollection<TEntity>> FindAsync(
Expression<Func<TEntity, bool>> criteria,
Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> orderBy = null,
string includeProperties = "");
Task<ICollection<TEntity>> FindAsync(
CancellationToken cancellationToken,
Expression<Func<TEntity, bool>> criteria,
Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> orderBy = null,
string includeProperties = "");
TEntity FindById(params object[] keyValues);
Task<TEntity> FindByIdAsync(params object[] keyValues);
Task<TEntity> FindByIdAsync(CancellationToken cancellationToken, params object[] keyValues);
void Delete(TEntity entity);
bool Delete(params object[] keyValues);
Task<bool> DeleteAsync(params object[] keyValues);
Task<bool> DeleteAsync(CancellationToken cancellationToken, params object[] keyValues);
void Insert(TEntity entity);
void Update(TEntity entity);
}
public interface IUnitOfWork
{
IDataRepository<TEntity> Repository<TEntity>() where TEntity : class;
int Save();
Task<int> SaveAsync();
Task<int> SaveAsync(CancellationToken cancellationToken);
void BeginTransaction(IsolationLevel isolationLevel = IsolationLevel.Unspecified);
bool Commit();
void Rollback();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment