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:
parent
e2853b64d1
commit
63c97b4dc7
@ -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)
|
||||
|
||||
@ -13,7 +13,9 @@ public interface IRepository<TEntity>
|
||||
|
||||
public IQueryable<TEntity> Where(Expression<Func<TEntity, bool>> expression);
|
||||
|
||||
public IQueryable<TEntity> Get();
|
||||
public IEnumerable<TEntity> GetAll();
|
||||
|
||||
public Task<IEnumerable<TEntity>> GetAllAsync();
|
||||
|
||||
public Task UpdateAsync<TDto>(TDto dto, Expression<Func<TEntity, bool>> expression, CancellationToken cancel = default);
|
||||
|
||||
@ -24,10 +26,10 @@ public interface IRepository<TEntity>
|
||||
public Task DeleteAsync(Func<IQueryable<TEntity>, IQueryable<TEntity>> query, CancellationToken cancel = default);
|
||||
|
||||
#region Obsolete
|
||||
[Obsolete("Use IRepository<TEntity>.Where")]
|
||||
[Obsolete("Use CreateAsync, UpdateAsync or DeleteAsync")]
|
||||
public IQueryable<TEntity> Read();
|
||||
|
||||
[Obsolete("Use IRepository<TEntity>.Get")]
|
||||
[Obsolete("Use IRepository<TEntity>.Where")]
|
||||
public IQueryable<TEntity> ReadOnly();
|
||||
#endregion
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user