refactor: ICRUDService, CRUDService, CRUDRepository und ICRUDRepository um IUnique<TId> Einschränkung zu erzwingen
- `IUnique<TId>` 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<TId>` implementieren.
This commit is contained in:
@@ -4,7 +4,7 @@ using DigitalData.Core.DTO;
|
|||||||
namespace DigitalData.Core.Abstractions.Application
|
namespace DigitalData.Core.Abstractions.Application
|
||||||
{
|
{
|
||||||
public interface ICRUDService<TCreateDto, TReadDto, TUpdateDto, TEntity, TId>
|
public interface ICRUDService<TCreateDto, TReadDto, TUpdateDto, TEntity, TId>
|
||||||
where TCreateDto : class where TReadDto : class where TUpdateDto : IUnique<TId> where TEntity : class
|
where TCreateDto : class where TReadDto : class where TUpdateDto : IUnique<TId> where TEntity : class, IUnique<TId>
|
||||||
{
|
{
|
||||||
Task<DataResult<TId>> CreateAsync(TCreateDto createDto);
|
Task<DataResult<TId>> CreateAsync(TCreateDto createDto);
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TEntity">The type of the entity this repository works with.</typeparam>
|
/// <typeparam name="TEntity">The type of the entity this repository works with.</typeparam>
|
||||||
/// <typeparam name="TId">The type of the identifier for the entity.</typeparam>
|
/// <typeparam name="TId">The type of the identifier for the entity.</typeparam>
|
||||||
public interface ICRUDRepository<TEntity, TId> where TEntity : class
|
public interface ICRUDRepository<TEntity, TId> where TEntity : class, IUnique<TId>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adds a new entity to the repository.
|
/// Adds a new entity to the repository.
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ namespace DigitalData.Core.Application
|
|||||||
/// <typeparam name="TEntity">The entity type.</typeparam>
|
/// <typeparam name="TEntity">The entity type.</typeparam>
|
||||||
/// <typeparam name="TId">The type of the identifier for the entity.</typeparam>
|
/// <typeparam name="TId">The type of the identifier for the entity.</typeparam>
|
||||||
public class CRUDService<TCRUDRepository, TCreateDto, TReadDto, TUpdateDto, TEntity, TId> : ICRUDService<TCreateDto, TReadDto, TUpdateDto, TEntity, TId>
|
public class CRUDService<TCRUDRepository, TCreateDto, TReadDto, TUpdateDto, TEntity, TId> : ICRUDService<TCreateDto, TReadDto, TUpdateDto, TEntity, TId>
|
||||||
where TCRUDRepository : ICRUDRepository<TEntity, TId> where TCreateDto : class where TReadDto : class where TUpdateDto : IUnique<TId> where TEntity : class
|
where TCRUDRepository : ICRUDRepository<TEntity, TId> where TCreateDto : class where TReadDto : class where TUpdateDto : IUnique<TId> where TEntity : class, IUnique<TId>
|
||||||
{
|
{
|
||||||
protected readonly TCRUDRepository _repository;
|
protected readonly TCRUDRepository _repository;
|
||||||
protected readonly IMapper _mapper;
|
protected readonly IMapper _mapper;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using DigitalData.Core.Abstractions.Infrastructure;
|
using DigitalData.Core.Abstractions;
|
||||||
|
using DigitalData.Core.Abstractions.Infrastructure;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace DigitalData.Core.Infrastructure
|
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.
|
/// It leverages the EF Core's DbContext and DbSet to perform these operations.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public class CRUDRepository<TEntity, TId, TDbContext> : ICRUDRepository<TEntity, TId>
|
public class CRUDRepository<TEntity, TId, TDbContext> : ICRUDRepository<TEntity, TId>
|
||||||
where TEntity : class
|
where TEntity : class, IUnique<TId>
|
||||||
where TDbContext : DbContext
|
where TDbContext : DbContext
|
||||||
{
|
{
|
||||||
protected readonly TDbContext _dbContext;
|
protected readonly TDbContext _dbContext;
|
||||||
|
|||||||
Reference in New Issue
Block a user