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<RecActionView>`.
- Refactored `ReadRecActionQueryHandler` to use `IRepository<RecActionView>`.
- 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.
This commit is contained in:
tekh 2025-12-01 13:32:57 +01:00
parent 8ef48942a3
commit 4b9f375646
6 changed files with 7 additions and 7 deletions

View File

@ -7,6 +7,6 @@ public class DtoMappingProfile : Profile
{
public DtoMappingProfile()
{
CreateMap<RecAction, RecActionDto>();
CreateMap<RecActionView, RecActionDto>();
}
}

View File

@ -7,7 +7,7 @@ public interface IRecDbContext
{
public DbSet<EndpointParam> EndpointParams { get; }
public DbSet<RecAction> Actions { get; }
public DbSet<RecActionView> Actions { get; }
public DbSet<OutRes> OutRes { get; }

View File

@ -17,7 +17,7 @@ public record ReadRecActionQueryBase
public record ReadRecActionQuery(ReadRecActionQueryBase Root) : ReadRecActionQueryBase(Root), IRequest<IEnumerable<RecActionDto>>;
public class ReadRecActionQueryHandler(IRepository<RecAction> repo, IMapper mapper) : IRequestHandler<ReadRecActionQuery, IEnumerable<RecActionDto>>
public class ReadRecActionQueryHandler(IRepository<RecActionView> repo, IMapper mapper) : IRequestHandler<ReadRecActionQuery, IEnumerable<RecActionDto>>
{
public async Task<IEnumerable<RecActionDto>> Handle(ReadRecActionQuery request, CancellationToken cancel)
{

View File

@ -12,7 +12,7 @@ namespace ReC.Domain.Entities;
/// requiring immediate code updates.
/// </summary>
[Table("VWREC_ACTION", Schema = "dbo")]
public class RecAction
public class RecActionView
{
[Column("ACTION_ID")]
public required long Id { get; set; }

View File

@ -21,7 +21,7 @@ public static class DependencyInjection
services.AddScoped<IRecDbContext>(provider => provider.GetRequiredService<TRecDbContext>());
services.AddDbRepository(opt => opt.RegisterFromAssembly<TRecDbContext>(typeof(RecAction).Assembly));
services.AddDbRepository(opt => opt.RegisterFromAssembly<TRecDbContext>(typeof(RecActionView).Assembly));
return services;
}

View File

@ -8,7 +8,7 @@ public class RecDbContext(DbContextOptions<RecDbContext> options) : DbContext(op
{
public DbSet<EndpointParam> EndpointParams { get; set; }
public DbSet<RecAction> Actions { get; set; }
public DbSet<RecActionView> Actions { get; set; }
public DbSet<OutRes> OutRes { get; set; }
@ -20,7 +20,7 @@ public class RecDbContext(DbContextOptions<RecDbContext> options) : DbContext(op
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<RecAction>().HasNoKey();
modelBuilder.Entity<RecActionView>().HasNoKey();
modelBuilder.Entity<HeaderQueryResult>().HasNoKey();