TekH 63c97b4dc7 feat(repository): add GetAll and GetAllAsync methods to IRepository
- Introduced GetAll() and GetAllAsync() to provide full entity retrieval options.
- Updated obsolete warnings:
  - Read() now marked with "Use CreateAsync, UpdateAsync or DeleteAsync".
  - ReadOnly() points to IRepository<TEntity>.Where.
- Removed old Get() method in favor of new retrieval methods.
2025-09-12 11:44:02 +02:00

40 lines
1.4 KiB
C#

using AutoMapper;
using System.Linq.Expressions;
namespace DigitalData.Core.Abstraction.Application.Repository;
public interface IRepository<TEntity>
{
public IMapper Mapper { get; }
public Task<TEntity> CreateAsync(TEntity entity, CancellationToken cancel = default);
public Task<IEnumerable<TEntity>> CreateAsync(IEnumerable<TEntity> entities, CancellationToken cancel = default);
public IQueryable<TEntity> Where(Expression<Func<TEntity, bool>> expression);
public IEnumerable<TEntity> GetAll();
public Task<IEnumerable<TEntity>> GetAllAsync();
public Task UpdateAsync<TDto>(TDto dto, Expression<Func<TEntity, bool>> expression, CancellationToken cancel = default);
public Task UpdateAsync<TDto>(TDto dto, Func<IQueryable<TEntity>, IQueryable<TEntity>> query, CancellationToken cancel = default);
public Task DeleteAsync(Expression<Func<TEntity, bool>> expression, CancellationToken cancel = default);
public Task DeleteAsync(Func<IQueryable<TEntity>, IQueryable<TEntity>> query, CancellationToken cancel = default);
#region Obsolete
[Obsolete("Use CreateAsync, UpdateAsync or DeleteAsync")]
public IQueryable<TEntity> Read();
[Obsolete("Use IRepository<TEntity>.Where")]
public IQueryable<TEntity> ReadOnly();
#endregion
}
public interface IRepository
{
public IRepository<TEntity> Entity<TEntity>() where TEntity : IEntity;
}