From 4b9f375646e30876a38c4456f089dca53f33181a Mon Sep 17 00:00:00 2001 From: TekH Date: Mon, 1 Dec 2025 13:32:57 +0100 Subject: [PATCH] Refactor to use RecActionView instead of RecAction Replaced `RecAction` with `RecActionView` across the codebase to align with the `VWREC_ACTION` database view. Updated mappings, interfaces, and repository registrations accordingly. - Updated `DtoMappingProfile` to map `RecActionView` to `RecActionDto`. - Modified `IRecDbContext` to use `DbSet`. - Refactored `ReadRecActionQueryHandler` to use `IRepository`. - Removed the `RecAction` class entirely. - Updated `DependencyInjection` to register `RecActionView`. - Adjusted `RecDbContext` to replace `RecAction` with `RecActionView` and configure it as a keyless entity. - Introduced the `RecActionView` class, mirroring the structure of the removed `RecAction` class, with nullable properties for schema flexibility. --- src/ReC.Application/Common/Dto/DtoMappingProfile.cs | 2 +- src/ReC.Application/Common/Interfaces/IRecDbContext.cs | 2 +- src/ReC.Application/RecActions/Queries/ReadRecActionQuery.cs | 2 +- src/ReC.Domain/Entities/{RecAction.cs => RecActionView.cs} | 2 +- src/ReC.Infrastructure/DependencyInjection.cs | 2 +- src/ReC.Infrastructure/RecDbContext.cs | 4 ++-- 6 files changed, 7 insertions(+), 7 deletions(-) rename src/ReC.Domain/Entities/{RecAction.cs => RecActionView.cs} (99%) diff --git a/src/ReC.Application/Common/Dto/DtoMappingProfile.cs b/src/ReC.Application/Common/Dto/DtoMappingProfile.cs index 7a2c012..783f49a 100644 --- a/src/ReC.Application/Common/Dto/DtoMappingProfile.cs +++ b/src/ReC.Application/Common/Dto/DtoMappingProfile.cs @@ -7,6 +7,6 @@ public class DtoMappingProfile : Profile { public DtoMappingProfile() { - CreateMap(); + CreateMap(); } } diff --git a/src/ReC.Application/Common/Interfaces/IRecDbContext.cs b/src/ReC.Application/Common/Interfaces/IRecDbContext.cs index 730d6f9..7e1e78b 100644 --- a/src/ReC.Application/Common/Interfaces/IRecDbContext.cs +++ b/src/ReC.Application/Common/Interfaces/IRecDbContext.cs @@ -7,7 +7,7 @@ public interface IRecDbContext { public DbSet EndpointParams { get; } - public DbSet Actions { get; } + public DbSet Actions { get; } public DbSet OutRes { get; } diff --git a/src/ReC.Application/RecActions/Queries/ReadRecActionQuery.cs b/src/ReC.Application/RecActions/Queries/ReadRecActionQuery.cs index f3a1f26..59883eb 100644 --- a/src/ReC.Application/RecActions/Queries/ReadRecActionQuery.cs +++ b/src/ReC.Application/RecActions/Queries/ReadRecActionQuery.cs @@ -17,7 +17,7 @@ public record ReadRecActionQueryBase public record ReadRecActionQuery(ReadRecActionQueryBase Root) : ReadRecActionQueryBase(Root), IRequest>; -public class ReadRecActionQueryHandler(IRepository repo, IMapper mapper) : IRequestHandler> +public class ReadRecActionQueryHandler(IRepository repo, IMapper mapper) : IRequestHandler> { public async Task> Handle(ReadRecActionQuery request, CancellationToken cancel) { diff --git a/src/ReC.Domain/Entities/RecAction.cs b/src/ReC.Domain/Entities/RecActionView.cs similarity index 99% rename from src/ReC.Domain/Entities/RecAction.cs rename to src/ReC.Domain/Entities/RecActionView.cs index e2cba2c..3ef769f 100644 --- a/src/ReC.Domain/Entities/RecAction.cs +++ b/src/ReC.Domain/Entities/RecActionView.cs @@ -12,7 +12,7 @@ namespace ReC.Domain.Entities; /// requiring immediate code updates. /// [Table("VWREC_ACTION", Schema = "dbo")] -public class RecAction +public class RecActionView { [Column("ACTION_ID")] public required long Id { get; set; } diff --git a/src/ReC.Infrastructure/DependencyInjection.cs b/src/ReC.Infrastructure/DependencyInjection.cs index 6cb2e77..be0e7c6 100644 --- a/src/ReC.Infrastructure/DependencyInjection.cs +++ b/src/ReC.Infrastructure/DependencyInjection.cs @@ -21,7 +21,7 @@ public static class DependencyInjection services.AddScoped(provider => provider.GetRequiredService()); - services.AddDbRepository(opt => opt.RegisterFromAssembly(typeof(RecAction).Assembly)); + services.AddDbRepository(opt => opt.RegisterFromAssembly(typeof(RecActionView).Assembly)); return services; } diff --git a/src/ReC.Infrastructure/RecDbContext.cs b/src/ReC.Infrastructure/RecDbContext.cs index 4ee76e2..ff573ad 100644 --- a/src/ReC.Infrastructure/RecDbContext.cs +++ b/src/ReC.Infrastructure/RecDbContext.cs @@ -8,7 +8,7 @@ public class RecDbContext(DbContextOptions options) : DbContext(op { public DbSet EndpointParams { get; set; } - public DbSet Actions { get; set; } + public DbSet Actions { get; set; } public DbSet OutRes { get; set; } @@ -20,7 +20,7 @@ public class RecDbContext(DbContextOptions options) : DbContext(op { base.OnModelCreating(modelBuilder); - modelBuilder.Entity().HasNoKey(); + modelBuilder.Entity().HasNoKey(); modelBuilder.Entity().HasNoKey();