diff --git a/DigitalData.Core.Abstractions/Infrastructure/ICRUDRepository.cs b/DigitalData.Core.Abstractions/Infrastructure/ICRUDRepository.cs index 3acf834..c5562ff 100644 --- a/DigitalData.Core.Abstractions/Infrastructure/ICRUDRepository.cs +++ b/DigitalData.Core.Abstractions/Infrastructure/ICRUDRepository.cs @@ -46,5 +46,17 @@ /// /// The total number of entities in the repository. Task CountAsync(); + + /// + /// Asynchronously counts the number of entities in the repository that match a specific identifier. + /// + /// The identifier of the entities to count. + /// The number of entities with the specified identifier. + /// + /// This method provides a count of entities in the database that match the given identifier. + /// If there are multiple entities with the same identifier, they will all be counted. + /// The default implementation assumes that the identifier is unique for each entity. + /// + Task CountAsync(TId id); } } \ No newline at end of file diff --git a/DigitalData.Core.Infrastructure/CRUDRepository.cs b/DigitalData.Core.Infrastructure/CRUDRepository.cs index 2a1bdd0..93de22e 100644 --- a/DigitalData.Core.Infrastructure/CRUDRepository.cs +++ b/DigitalData.Core.Infrastructure/CRUDRepository.cs @@ -96,5 +96,17 @@ namespace DigitalData.Core.Infrastructure /// /// The total number of entities in the repository. public virtual async Task CountAsync() => await _dbSet.CountAsync(); + + /// + /// Asynchronously counts the number of entities in the repository that match a specific identifier. + /// + /// The identifier of the entities to count. + /// The number of entities with the specified identifier. + /// + /// This method provides a count of entities in the database that match the given identifier. + /// If there are multiple entities with the same identifier, they will all be counted. + /// The default implementation assumes that the identifier is unique for each entity. + /// + public virtual async Task CountAsync(TId id) => await _dbSet.Where(e => e.Id!.Equals(id)).CountAsync(); } } \ No newline at end of file