/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
- using System;
- using System.Linq;
- using System.Linq.Expressions;
-
- namespace Gradebook.Contracts.Repositories
- {
- public interface IRepository<TEntity, in TKey>
- where TEntity : class
- {
- // CRUD functions
- void Create(TEntity entity);
- TEntity Read(TKey id);
- void Update(TEntity entity);
- void Delete(TEntity entity);
-
- // Additional functions
- IQueryable<TEntity> Get(
- Expression<Func<TEntity, bool>> filter = null,
- Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> orderBy = null,
- string includeProperties = "");
- IQueryable<TEntity> GetAll();
- bool TryRead(TKey id, out TEntity entity);
- void Delete(TKey id);
- long Count();
- bool Contains(TKey id);
- }
-
- public interface IRepository<TEntity> : IRepository<TEntity, int>
- where TEntity : class { }
-
- public interface IRepositoryBase<TEntity> : IRepository<TEntity, object>
- where TEntity : class { }
- }