Add CancellationToken support to IReadQuery methods

Updated the IReadQuery<TEntity> interface to include an optional CancellationToken parameter for the following asynchronous methods:
- FirstOrDefaultAsync
- SingleOrDefaultAsync
- ToListAsync
- FirstAsync
- SingleAsync

Documentation comments for these methods have also been updated to describe the new cancellation parameter and its purpose.
This commit is contained in:
Developer 02 2025-05-20 10:10:16 +02:00
parent a7df79629d
commit 36c2c20eab

View File

@ -21,32 +21,37 @@ public interface IReadQuery<TEntity>
/// <summary>
/// Asynchronously retrieves the first entity or a default value if no entity is found.
/// </summary>
/// <param name="cancellation">A <see cref="CancellationToken"/> to observe while waiting for the task to complete.</param>
/// <returns>A task that represents the asynchronous operation. The task result contains the entity or a default value.</returns>
public Task<TEntity?> FirstOrDefaultAsync();
public Task<TEntity?> FirstOrDefaultAsync(CancellationToken cancellation = default);
/// <summary>
/// Asynchronously retrieves a single entity or a default value if no entity is found.
/// </summary>
/// <param name="cancellation">A <see cref="CancellationToken"/> to observe while waiting for the task to complete.</param>
/// <returns>A task that represents the asynchronous operation. The task result contains the entity or a default value.</returns>
public Task<TEntity?> SingleOrDefaultAsync();
public Task<TEntity?> SingleOrDefaultAsync(CancellationToken cancellation = default);
/// <summary>
/// Asynchronously retrieves a list of entities.
/// </summary>
/// <param name="cancellation">A <see cref="CancellationToken"/> to observe while waiting for the task to complete.</param>
/// <returns>A task that represents the asynchronous operation. The task result contains the list of entities.</returns>
public Task<IEnumerable<TEntity>> ToListAsync();
public Task<IEnumerable<TEntity>> ToListAsync(CancellationToken cancellation = default);
/// <summary>
/// Asynchronously retrieves the first entity. Throws an exception if no entity is found.
/// </summary>
/// <param name="cancellation">A <see cref="CancellationToken"/> to observe while waiting for the task to complete.</param>
/// <returns>A task that represents the asynchronous operation. The task result contains the first entity.</returns>
public Task<TEntity> FirstAsync();
public Task<TEntity> FirstAsync(CancellationToken cancellation = default);
/// <summary>
/// Asynchronously retrieves a single entity. Throws an exception if no entity is found.
/// </summary>
/// <param name="cancellation">A <see cref="CancellationToken"/> to observe while waiting for the task to complete.</param>
/// <returns>A task that represents the asynchronous operation. The task result contains the single entity.</returns>
public Task<TEntity> SingleAsync();
public Task<TEntity> SingleAsync(CancellationToken cancellation = default);
/// <summary>
/// Synchronously retrieves the first entity or a default value if no entity is found.