diff --git a/DigitalData.Core.Abstractions/Infrastructure/ICRUDRepository.cs b/DigitalData.Core.Abstractions/Infrastructure/ICRUDRepository.cs index 4223d82..c8355e9 100644 --- a/DigitalData.Core.Abstractions/Infrastructure/ICRUDRepository.cs +++ b/DigitalData.Core.Abstractions/Infrastructure/ICRUDRepository.cs @@ -21,6 +21,16 @@ /// The entity found, or null if no entity is found. Task ReadByIdAsync(TId id); + /// + /// Retrieves all entities of type from the repository. + /// + /// + /// This method returns an 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. + /// + /// An containing all entities of type in the repository. + protected IQueryable ReadAll(); + /// /// Retrieves all entities from the repository. /// diff --git a/DigitalData.Core.Infrastructure/CRUDRepository.cs b/DigitalData.Core.Infrastructure/CRUDRepository.cs index bde0e2a..f1688d9 100644 --- a/DigitalData.Core.Infrastructure/CRUDRepository.cs +++ b/DigitalData.Core.Infrastructure/CRUDRepository.cs @@ -49,11 +49,21 @@ namespace DigitalData.Core.Infrastructure /// The entity found, or null if no entity is found with the specified identifier. public virtual async Task ReadByIdAsync(TId id) => await _dbSet.FindAsync(id); + /// + /// Retrieves all entities of type from the database. + /// + /// + /// This method returns an 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. + /// + /// An containing all entities of type . + protected virtual IQueryable ReadAll() => _dbSet.AsNoTracking(); + /// /// Asynchronously retrieves all entities of type TEntity. /// /// An enumerable of all entities in the database. - public virtual async Task> ReadAllAsync() => await _dbSet.ToListAsync(); + public virtual async Task> ReadAllAsync() => await ReadAll().ToListAsync(); /// /// Asynchronously updates an existing entity in the repository.