feat: ReadAll-Methode in ICRUDRepository und CRUDRepository implementieren
- ReadAll-Methode zur ICRUDRepository-Schnittstelle hinzugefügt, um die Abfrage aller Entitäten zu ermöglichen. - ReadAll-Methode in der CRUDRepository-Klasse implementiert, um IQueryable<TEntity> für weitere Abfragen und Filterung bereitzustellen.
This commit is contained in:
parent
67a3c598b1
commit
ee5668a5cb
@ -21,6 +21,16 @@
|
||||
/// <returns>The entity found, or null if no entity is found.</returns>
|
||||
Task<TEntity?> ReadByIdAsync(TId id);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all entities of type <typeparamref name="TEntity"/> from the repository.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method returns an <see cref="IQueryable{TEntity}"/> that represents all entities in the repository.
|
||||
/// The result is an IQueryable that allows for further querying and filtering to be applied by the caller.
|
||||
/// </remarks>
|
||||
/// <returns>An <see cref="IQueryable{TEntity}"/> containing all entities of type <typeparamref name="TEntity"/> in the repository.</returns>
|
||||
protected IQueryable<TEntity> ReadAll();
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all entities from the repository.
|
||||
/// </summary>
|
||||
|
||||
@ -49,11 +49,21 @@ namespace DigitalData.Core.Infrastructure
|
||||
/// <returns>The entity found, or null if no entity is found with the specified identifier.</returns>
|
||||
public virtual async Task<TEntity?> ReadByIdAsync(TId id) => await _dbSet.FindAsync(id);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all entities of type <typeparamref name="TEntity"/> from the database.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method returns an <see cref="IQueryable{TEntity}"/> of all entities in the database.
|
||||
/// The result is not tracked by the context, which improves performance when you only need to read data without making modifications.
|
||||
/// </remarks>
|
||||
/// <returns>An <see cref="IQueryable{TEntity}"/> containing all entities of type <typeparamref name="TEntity"/>.</returns>
|
||||
protected virtual IQueryable<TEntity> ReadAll() => _dbSet.AsNoTracking();
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously retrieves all entities of type TEntity.
|
||||
/// </summary>
|
||||
/// <returns>An enumerable of all entities in the database.</returns>
|
||||
public virtual async Task<IEnumerable<TEntity>> ReadAllAsync() => await _dbSet.ToListAsync();
|
||||
public virtual async Task<IEnumerable<TEntity>> ReadAllAsync() => await ReadAll().ToListAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously updates an existing entity in the repository.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user