From Buff Earthworm, 10 Years ago, written in Plain Text.
Embed
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Linq.Expressions;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace Pasted.DataAccess
  9. {
  10.     public interface IRepository
  11.     {
  12.         /// <summary>
  13.         /// Gets all.
  14.         /// </summary>
  15.         /// <typeparam name="TEntity">The type of the entity.</typeparam>
  16.         /// <returns></returns>
  17.         IEnumerable<TEntity> GetAll<TEntity>() where TEntity : class;
  18.  
  19.         /// <summary>
  20.         /// Finds entities based on provided criteria.
  21.         /// </summary>
  22.         /// <typeparam name="TEntity">The type of the entity.</typeparam>
  23.         /// <param name="criteria">The criteria.</param>
  24.         /// <returns></returns>
  25.         IEnumerable<TEntity> Find<TEntity>(Expression<Func<TEntity, bool>> criteria) where TEntity : class;
  26.  
  27.         /// <summary>
  28.         /// Finds one entity based on provided criteria.
  29.         /// </summary>
  30.         /// <typeparam name="TEntity">The type of the entity.</typeparam>
  31.         /// <param name="criteria">The criteria.</param>
  32.         /// <returns></returns>
  33.         TEntity FindOne<TEntity>(Expression<Func<TEntity, bool>> criteria) where TEntity : class;
  34.  
  35.         /// <summary>
  36.         /// Adds the specified entity.
  37.         /// </summary>
  38.         /// <typeparam name="TEntity">The type of the entity.</typeparam>
  39.         /// <param name="entity">The entity.</param>
  40.         void Add<TEntity>(TEntity entity) where TEntity : class;
  41.  
  42.         /// <summary>
  43.         /// Updates changes of the existing entity.
  44.         /// The caller must later call SaveChanges() on the repository explicitly to save the entity to database
  45.         /// </summary>
  46.         /// <typeparam name="TEntity">The type of the entity.</typeparam>
  47.         /// <param name="entity">The entity.</param>
  48.         void Update<TEntity>(TEntity entity) where TEntity : class;
  49.  
  50.         /// <summary>
  51.         /// Deletes the specified entity.
  52.         /// </summary>
  53.         /// <typeparam name="TEntity">The type of the entity.</typeparam>
  54.         /// <param name="entity">The entity.</param>
  55.         void Delete<TEntity>(TEntity entity) where TEntity : class;
  56.     }
  57. }
  58.