Refactor repository pattern and mark methods obsolete

Updated `IRepository<TEntity>` to introduce new reading methods and mark existing ones as obsolete. The `CRUDRepository` class is now deprecated, encouraging a transition to alternative implementations. Significant changes in `DbRepository<TDbContext, TEntity>` include the removal of old read methods in favor of a new `Read` method returning `IReadQuery<TEntity>`. Added a `ReadQuery<TEntity>` class to enhance querying capabilities with a fluent API. Obsolete methods are organized under a `#region Obsolete` directive for better management.
This commit is contained in:
Developer 02
2025-05-20 10:35:27 +02:00
parent 5995b334eb
commit f7e2bb2434
4 changed files with 79 additions and 20 deletions

View File

@@ -16,6 +16,7 @@ public interface IRepository<TEntity>
public Task DeleteAsync(Expression<Func<TEntity, bool>> expression, CancellationToken cancellation = default);
#region Obsolete
[Obsolete("Use Read-method returning IReadQuery<TEntity> instead.")]
public Task<IEnumerable<TEntity>> ReadAllAsync(Expression<Func<TEntity, bool>>? expression = null, CancellationToken cancellation = default);
@@ -27,4 +28,5 @@ public interface IRepository<TEntity>
[Obsolete("Use Read-method returning IReadQuery<TEntity> instead.")]
public Task<TDto?> ReadOrDefaultAsync<TDto>(Expression<Func<TEntity, bool>> expression, bool single = true, CancellationToken cancellation = default);
#endregion
}