Update RecActionView model and mapping for enums and names

Refactored RecActionView to use enum types for EndpointAuthType, ApiKeyLocation, and RestType, and added properties for their display names. Introduced ErrorAction and its display name. Updated RecDbContext mapping to treat RecActionView as a view with a key, map new enum ID and name fields, and align property mappings with the database view structure. This enhances clarity and supports both ID and human-readable values in the model.
This commit is contained in:
2025-12-15 12:01:39 +01:00
parent 784b4b1f05
commit 0afe9870c0
2 changed files with 22 additions and 7 deletions

View File

@@ -44,12 +44,16 @@ public class RecActionView
public EndpointAuthType? EndpointAuthType { get; set; }
public string? EndpointAuthTypeName { get; set; }
public string? EndpointAuthApiKey { get; set; }
public string? EndpointAuthApiValue { get; set; }
public ApiKeyLocation? EndpointAuthApiKeyAddTo { get; set; }
public string? EndpointAuthApiKeyAddToName { get; set; }
public string? EndpointAuthToken { get; set; }
public string? EndpointAuthUsername { get; set; }
@@ -75,7 +79,9 @@ public class RecActionView
public string? SqlConnectionPassword { get; set; }
public string? RestType { get; set; }
public RestType? RestType { get; set; }
public string? RestTypeName { get; set; }
public string? PreprocessingQuery { get; set; }
@@ -84,4 +90,8 @@ public class RecActionView
public string? BodyQuery { get; set; }
public string? PostprocessingQuery { get; set; }
public ErrorAction? ErrorAction { get; set; }
public string? ErrorActionName { get; set; }
}

View File

@@ -196,10 +196,10 @@ public class RecDbContext(DbContextOptions<RecDbContext> options) : DbContext(op
modelBuilder.Entity<RecActionView>(b =>
{
b.ToTable("VWREC_ACTION", "dbo");
b.HasNoKey();
b.ToView("VWREC_ACTION", "dbo");
b.HasKey(e => e.Id);
b.Property(e => e.Id).HasColumnName("ACTION_ID");
b.Property(e => e.Id).HasColumnName("ACTION_GUID");
b.Property(e => e.ProfileId).HasColumnName("PROFILE_ID");
b.Property(e => e.ProfileName).HasColumnName("PROFILE_NAME");
b.Property(e => e.ProfileType).HasColumnName("PROFILE_TYPE");
@@ -207,10 +207,12 @@ public class RecDbContext(DbContextOptions<RecDbContext> options) : DbContext(op
b.Property(e => e.EndpointId).HasColumnName("ENDPOINT_ID");
b.Property(e => e.EndpointUri).HasColumnName("ENDPOINT_URI");
b.Property(e => e.EndpointAuthId).HasColumnName("ENDPOINT_AUTH_ID");
b.Property(e => e.EndpointAuthType).HasColumnName("ENDPOINT_AUTH_TYPE");
b.Property(e => e.EndpointAuthType).HasColumnName("ENDPOINT_AUTH_TYPE_ID");
b.Property(e => e.EndpointAuthTypeName).HasColumnName("ENDPOINT_AUTH_TYPE");
b.Property(e => e.EndpointAuthApiKey).HasColumnName("ENDPOINT_AUTH_API_KEY");
b.Property(e => e.EndpointAuthApiValue).HasColumnName("ENDPOINT_AUTH_API_VALUE");
b.Property(e => e.EndpointAuthApiKeyAddTo).HasColumnName("ENDPOINT_AUTH_API_KEY_ADD_TO");
b.Property(e => e.EndpointAuthApiKeyAddTo).HasColumnName("ENDPOINT_AUTH_API_KEY_ADD_TO_ID");
b.Property(e => e.EndpointAuthApiKeyAddToName).HasColumnName("ENDPOINT_AUTH_API_KEY_ADD_TO");
b.Property(e => e.EndpointAuthToken).HasColumnName("ENDPOINT_AUTH_TOKEN");
b.Property(e => e.EndpointAuthUsername).HasColumnName("ENDPOINT_AUTH_USERNAME");
b.Property(e => e.EndpointAuthPassword).HasColumnName("ENDPOINT_AUTH_PASSWORD");
@@ -222,11 +224,14 @@ public class RecDbContext(DbContextOptions<RecDbContext> options) : DbContext(op
b.Property(e => e.SqlConnectionDb).HasColumnName("SQL_CONNECTION_DB");
b.Property(e => e.SqlConnectionUsername).HasColumnName("SQL_CONNECTION_USERNAME");
b.Property(e => e.SqlConnectionPassword).HasColumnName("SQL_CONNECTION_PASSWORD");
b.Property(e => e.RestType).HasColumnName("REST_TYPE");
b.Property(e => e.RestType).HasColumnName("REST_TYPE_ID");
b.Property(e => e.RestTypeName).HasColumnName("REST_TYPE");
b.Property(e => e.PreprocessingQuery).HasColumnName("PREPROCESSING_QUERY");
b.Property(e => e.HeaderQuery).HasColumnName("HEADER_QUERY");
b.Property(e => e.BodyQuery).HasColumnName("BODY_QUERY");
b.Property(e => e.PostprocessingQuery).HasColumnName("POSTPROCESSING_QUERY");
b.Property(e => e.ErrorAction).HasColumnName("ERROR_ACTION_ID");
b.Property(e => e.ErrorActionName).HasColumnName("ERROR_ACTION");
});
modelBuilder.Entity<HeaderQueryResult>(b =>