From a6230419d89b17520dd94c55dd91c932250092e1 Mon Sep 17 00:00:00 2001 From: Developer 02 Date: Wed, 11 Sep 2024 09:54:26 +0200 Subject: [PATCH] =?UTF-8?q?refactor:=20`ICRUDService`,=20`CRUDService`,=20?= =?UTF-8?q?`CRUDRepository`=20und=20`ICRUDRepository`=20um=20`IUnique?= =?UTF-8?q?`=20Einschr=C3=A4nkung=20zu=20erzwingen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - `IUnique` Einschränkung zu `TEntity` in den Schnittstellen `ICRUDService`, `CRUDService`, `ICRUDRepository` und `CRUDRepository` hinzugefügt. - Relevanten Code aktualisiert, um die neue Einschränkung zu berücksichtigen und sicherzustellen, dass Entitäten `IUnique` implementieren. --- DigitalData.Core.Abstractions/Application/ICRUDService.cs | 2 +- .../Infrastructure/ICRUDRepository.cs | 2 +- DigitalData.Core.Application/CRUDService.cs | 2 +- DigitalData.Core.Infrastructure/CRUDRepository.cs | 5 +++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/DigitalData.Core.Abstractions/Application/ICRUDService.cs b/DigitalData.Core.Abstractions/Application/ICRUDService.cs index 9dfec8d..2c6074d 100644 --- a/DigitalData.Core.Abstractions/Application/ICRUDService.cs +++ b/DigitalData.Core.Abstractions/Application/ICRUDService.cs @@ -4,7 +4,7 @@ using DigitalData.Core.DTO; namespace DigitalData.Core.Abstractions.Application { public interface ICRUDService - where TCreateDto : class where TReadDto : class where TUpdateDto : IUnique where TEntity : class + where TCreateDto : class where TReadDto : class where TUpdateDto : IUnique where TEntity : class, IUnique { Task> CreateAsync(TCreateDto createDto); diff --git a/DigitalData.Core.Abstractions/Infrastructure/ICRUDRepository.cs b/DigitalData.Core.Abstractions/Infrastructure/ICRUDRepository.cs index 4223d82..15e022f 100644 --- a/DigitalData.Core.Abstractions/Infrastructure/ICRUDRepository.cs +++ b/DigitalData.Core.Abstractions/Infrastructure/ICRUDRepository.cs @@ -5,7 +5,7 @@ /// /// The type of the entity this repository works with. /// The type of the identifier for the entity. - public interface ICRUDRepository where TEntity : class + public interface ICRUDRepository where TEntity : class, IUnique { /// /// Adds a new entity to the repository. diff --git a/DigitalData.Core.Application/CRUDService.cs b/DigitalData.Core.Application/CRUDService.cs index 21cca2e..d737680 100644 --- a/DigitalData.Core.Application/CRUDService.cs +++ b/DigitalData.Core.Application/CRUDService.cs @@ -18,7 +18,7 @@ namespace DigitalData.Core.Application /// The entity type. /// The type of the identifier for the entity. public class CRUDService : ICRUDService - where TCRUDRepository : ICRUDRepository where TCreateDto : class where TReadDto : class where TUpdateDto : IUnique where TEntity : class + where TCRUDRepository : ICRUDRepository where TCreateDto : class where TReadDto : class where TUpdateDto : IUnique where TEntity : class, IUnique { protected readonly TCRUDRepository _repository; protected readonly IMapper _mapper; diff --git a/DigitalData.Core.Infrastructure/CRUDRepository.cs b/DigitalData.Core.Infrastructure/CRUDRepository.cs index 1ac6b45..db8b902 100644 --- a/DigitalData.Core.Infrastructure/CRUDRepository.cs +++ b/DigitalData.Core.Infrastructure/CRUDRepository.cs @@ -1,4 +1,5 @@ -using DigitalData.Core.Abstractions.Infrastructure; +using DigitalData.Core.Abstractions; +using DigitalData.Core.Abstractions.Infrastructure; using Microsoft.EntityFrameworkCore; namespace DigitalData.Core.Infrastructure @@ -14,7 +15,7 @@ namespace DigitalData.Core.Infrastructure /// It leverages the EF Core's DbContext and DbSet to perform these operations. /// public class CRUDRepository : ICRUDRepository - where TEntity : class + where TEntity : class, IUnique where TDbContext : DbContext { protected readonly TDbContext _dbContext;