From 21c895c22bdde604069468d6e0699f7f11bc5b7b Mon Sep 17 00:00:00 2001 From: Developer 02 Date: Tue, 20 May 2025 10:00:18 +0200 Subject: [PATCH] Enhance IRepository with async methods and deprecations Updated the `IRepository` interface in `IRepository.cs` to include new asynchronous methods for reading, updating, and deleting entities. Added `Read`, `UpdateAsync`, and `DeleteAsync` methods while marking several existing methods as obsolete to encourage the use of the new `Read` method returning `IReadQuery`. Removed previous implementations of `UpdateAsync` and `DeleteAsync` for a more streamlined API. --- .../Interfaces/Repository/IRepository.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/DigitalData.Core.Application/Interfaces/Repository/IRepository.cs b/DigitalData.Core.Application/Interfaces/Repository/IRepository.cs index 885a055..88a65fa 100644 --- a/DigitalData.Core.Application/Interfaces/Repository/IRepository.cs +++ b/DigitalData.Core.Application/Interfaces/Repository/IRepository.cs @@ -9,16 +9,22 @@ public interface IRepository public Task CreateAsync(TEntity entity, CancellationToken ct = default); public Task> CreateAsync(IEnumerable entities, CancellationToken ct = default); - + + public IReadQuery Read(Expression> expression, CancellationToken ct = default); + + public Task UpdateAsync(TDto dto, Expression> expression, CancellationToken ct = default); + + public Task DeleteAsync(Expression> expression, CancellationToken ct = default); + + [Obsolete("Use Read-method returning IReadQuery instead.")] public Task> ReadAllAsync(Expression>? expression = null, CancellationToken ct = default); + [Obsolete("Use Read-method returning IReadQuery instead.")] public Task ReadOrDefaultAsync(Expression> expression, bool single = true, CancellationToken ct = default); + [Obsolete("Use Read-method returning IReadQuery instead.")] public Task> ReadAllAsync(Expression>? expression = null, CancellationToken ct = default); + [Obsolete("Use Read-method returning IReadQuery instead.")] public Task ReadOrDefaultAsync(Expression> expression, bool single = true, CancellationToken ct = default); - - public Task UpdateAsync(TDto dto, Expression> expression, CancellationToken ct = default); - - public Task DeleteAsync(Expression> expression, CancellationToken ct = default); }