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.
This commit is contained in:
2025-09-12 11:44:02 +02:00
parent e2853b64d1
commit 63c97b4dc7
2 changed files with 12 additions and 5 deletions

View File

@@ -19,12 +19,17 @@ public static class Extensions
#endregion
#region IRepository
public static IQueryable<TEntity> Get<TEntity>(this IRepository repository) where TEntity : IEntity
=> repository.Entity<TEntity>().Get();
#region Read
public static IEnumerable<TEntity> GetAll<TEntity>(this IRepository repository) where TEntity : IEntity
=> repository.Entity<TEntity>().GetAll();
public static Task<IEnumerable<TEntity>> GetAllAsync<TEntity>(this IRepository repository) where TEntity : IEntity
=> repository.Entity<TEntity>().GetAllAsync();
public static IQueryable<TEntity> Where<TEntity>(this IRepository repository, Expression<Func<TEntity, bool>> expression)
where TEntity : IEntity
=> repository.Entity<TEntity>().Where(expression);
#endregion
#region Create
public static Task<TEntity> CreateAsync<TEntity>(this IRepository repository, TEntity entity, CancellationToken cancel = default)