Repositorios para acceder a las bases de datos
Visual Studio >= 2019
NET TargetFramework >= net5.0
Net Core SDK >= 5.0.100
C# >= 9.0
Conocimientos sobre Inyección de Dependencias
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
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 { }
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);
}
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 { }
No son necesarias porque son interfaces, las pruebas serán realizadas en su implementación
Kitpymes 😊