PageRenderTime 42ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/Gradebook.Contracts/Repositories/IRepository.cs

https://bitbucket.org/academium/gradebook
C# | 33 lines | 27 code | 4 blank | 2 comment | 0 complexity | 6d72203136175f66c60868c240e0fa74 MD5 | raw file
  1. using System;
  2. using System.Linq;
  3. using System.Linq.Expressions;
  4. namespace Gradebook.Contracts.Repositories
  5. {
  6. public interface IRepository<TEntity, in TKey>
  7. where TEntity : class
  8. {
  9. // CRUD functions
  10. void Create(TEntity entity);
  11. TEntity Read(TKey id);
  12. void Update(TEntity entity);
  13. void Delete(TEntity entity);
  14. // Additional functions
  15. IQueryable<TEntity> Get(
  16. Expression<Func<TEntity, bool>> filter = null,
  17. Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> orderBy = null,
  18. string includeProperties = "");
  19. IQueryable<TEntity> GetAll();
  20. bool TryRead(TKey id, out TEntity entity);
  21. void Delete(TKey id);
  22. long Count();
  23. bool Contains(TKey id);
  24. }
  25. public interface IRepository<TEntity> : IRepository<TEntity, int>
  26. where TEntity : class { }
  27. public interface IRepositoryBase<TEntity> : IRepository<TEntity, object>
  28. where TEntity : class { }
  29. }