feat: CountAsync-Methode zum Repository-Interface und zur Implementierung hinzugefügt
Eine neue asynchrone CountAsync-Methode wurde zum Repository-Interface und zur Implementierung hinzugefügt. Diese Methode zählt die Anzahl der Entitäten mit einer bestimmten ID in der Datenbank.
This commit is contained in:
parent
adfb0daf7d
commit
406a41b91f
@ -46,5 +46,17 @@
|
||||
/// </summary>
|
||||
/// <returns>The total number of entities in the repository.</returns>
|
||||
Task<int> CountAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously counts the number of entities in the repository that match a specific identifier.
|
||||
/// </summary>
|
||||
/// <param name="id">The identifier of the entities to count.</param>
|
||||
/// <returns>The number of entities with the specified identifier.</returns>
|
||||
/// <remarks>
|
||||
/// 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.
|
||||
/// </remarks>
|
||||
Task<int> CountAsync(TId id);
|
||||
}
|
||||
}
|
||||
@ -96,5 +96,17 @@ namespace DigitalData.Core.Infrastructure
|
||||
/// </summary>
|
||||
/// <returns>The total number of entities in the repository.</returns>
|
||||
public virtual async Task<int> CountAsync() => await _dbSet.CountAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously counts the number of entities in the repository that match a specific identifier.
|
||||
/// </summary>
|
||||
/// <param name="id">The identifier of the entities to count.</param>
|
||||
/// <returns>The number of entities with the specified identifier.</returns>
|
||||
/// <remarks>
|
||||
/// 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.
|
||||
/// </remarks>
|
||||
public virtual async Task<int> CountAsync(TId id) => await _dbSet.Where(e => e.Id!.Equals(id)).CountAsync();
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user