From 1b793e2b75e3832c2bf81ecf5cf15971e6cfb7e4 Mon Sep 17 00:00:00 2001 From: Developer 02 Date: Wed, 16 Apr 2025 09:17:38 +0200 Subject: [PATCH] Add CancellationToken support to IRepository methods Updated the IRepository interface to include an optional CancellationToken parameter in the asynchronous methods: CreateAsync, ReadAsync, UpdateAsync, and DeleteAsync. Modified the DbRepository class to align with these changes, ensuring method signatures are consistent with the interface. --- .../Infrastructure/IRepository.cs | 10 +++++----- DigitalData.Core.Infrastructure/DbRepository.cs | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/DigitalData.Core.Abstractions/Infrastructure/IRepository.cs b/DigitalData.Core.Abstractions/Infrastructure/IRepository.cs index fbd9581..781a1e2 100644 --- a/DigitalData.Core.Abstractions/Infrastructure/IRepository.cs +++ b/DigitalData.Core.Abstractions/Infrastructure/IRepository.cs @@ -4,13 +4,13 @@ namespace DigitalData.Core.Abstractions.Infrastructure; public interface IRepository { - public Task CreateAsync(TDto dto); + public Task CreateAsync(TDto dto, CancellationToken ct = default); - public Task CreateAsync(IEnumerable dtos); + public Task CreateAsync(IEnumerable dtos, CancellationToken ct = default); - public Task> ReadAsync(Expression? expression = null); + public Task> ReadAsync(Expression? expression = null, CancellationToken ct = default); - public Task> UpdateAsync(TDto dto, Expression expression); + public Task> UpdateAsync(TDto dto, Expression expression, CancellationToken ct = default); - public Task> DeleteAsync(Expression expression); + public Task> DeleteAsync(Expression expression, CancellationToken ct = default); } diff --git a/DigitalData.Core.Infrastructure/DbRepository.cs b/DigitalData.Core.Infrastructure/DbRepository.cs index c5be39b..61a70da 100644 --- a/DigitalData.Core.Infrastructure/DbRepository.cs +++ b/DigitalData.Core.Infrastructure/DbRepository.cs @@ -16,27 +16,27 @@ public class DbRepository : IRepository where TDbC Entities = queryFactory(context); } - public Task CreateAsync(TDto dto) + public Task CreateAsync(TDto dto, CancellationToken ct = default) { throw new NotImplementedException(); } - public Task CreateAsync(IEnumerable dtos) + public Task CreateAsync(IEnumerable dtos, CancellationToken ct = default) { throw new NotImplementedException(); } - public Task> DeleteAsync(Expression expression) + public Task> DeleteAsync(Expression expression, CancellationToken ct = default) { throw new NotImplementedException(); } - public Task> ReadAsync(Expression? expression = null) + public Task> ReadAsync(Expression? expression = null, CancellationToken ct = default) { throw new NotImplementedException(); } - public Task> UpdateAsync(TDto dto, Expression expression) + public Task> UpdateAsync(TDto dto, Expression expression, CancellationToken ct = default) { throw new NotImplementedException(); }