template-netcore-repositories

Kitpymes.Core.Repositories

Repositorios para acceder a las bases de datos

Build Status NuGet Status NuGet Download License: MIT Size Repo Last Commit

📋 Requerimientos

🔧 Instalación

Se puede instalar usando el administrador de paquetes Nuget o CLI dotnet.

Nuget

Install-Package Kitpymes.Core.Repositories

CLI dotnet

dotnet add package Kitpymes.Core.Repositories

⌨️ Código

Commands

public interface ICommandRepository<T>
        where T : class
    {
        void Add(T item);

        Task AddAsync(T item);

        void AddRange(IEnumerable<T> items);

        Task AddRangeAsync(IEnumerable<T> items);

        void Update(object key, T item);

        Task UpdateAsync(object key, T item);

        void UpdatePartial(object key, object item);

        Task UpdatePartialAsync(object key, object item);

        void Delete(object key);

        Task DeleteAsync(object key);

        void Delete(Expression<Func<T, bool>> where);

        Task DeleteAsync(Expression<Func<T, bool>> where);
    }
public interface ICommandRelationalRepository<T> : ICommandRepository<T>
    where T : class { }

Queries

 public interface IQueryRepository<T>
        where T : class
{
    T GetOne(Expression<Func<T, bool>> where);

    Task<T> GetOneAsync(Expression<Func<T, bool>> where);

    IEnumerable<T> GetAll();

    Task<IEnumerable<T>> GetAllAsync();

    IEnumerable<T> GetAll(Expression<Func<T, bool>> where);

    Task<IEnumerable<T>> GetAllAsync(Expression<Func<T, bool>> where);

    IEnumerable<T> GetPaged(Action<(string? property, bool? ascending, int? index, int? size)> parameters);

    Task<IEnumerable<T>> GetPagedAsync(Action<(string? property, bool? ascending, int? index, int? size)> parameters);

    T Find(object key);

    Task<T> FindAsync(object key);

    bool Any();

    Task<bool> AnyAsync();

    bool Any(Expression<Func<T, bool>> where);

    Task<bool> AnyAsync(Expression<Func<T, bool>> where);

    long Count();

    Task<long> CountAsync();

    long Count(Expression<Func<T, bool>> where);

    Task<long> CountAsync(Expression<Func<T, bool>> where);
}

IUnitOfWork

public interface IUnitOfWork
{
    void OpenTransaction(IsolationLevel isolationLevel = IsolationLevel.ReadCommitted);

    void Save();
}
public interface IRepository<T> : ICommandRepository<T>, IQueryRepository<T>
    where T : class { }
public interface IRelationalRepository<T> : IRepository<T>, ICommandRelationalRepository<T>, IQueryRelationalRepository<T>
    where T : class { }

⚙️ Pruebas Unitarias

No son necesarias porque son interfaces, las pruebas serán realizadas en su implementación

🛠️ Construido con

✒️ Autores

📄 Licencia

🎁 Gratitud


Kitpymes 😊