From fa9aa23f3255daf07a7c6d4ede423fc824d49072 Mon Sep 17 00:00:00 2001 From: TekH Date: Thu, 26 Mar 2026 10:30:00 +0100 Subject: [PATCH] Add EF Core data annotations to view models Added [Key], [Column], and [Table] attributes to ProfileView, RecActionView, and ResultView classes to explicitly map properties to database columns and views. Expanded model properties for clearer schema alignment and improved maintainability with Entity Framework Core. --- src/ReC.Domain/Views/ProfileView.cs | 28 ++++++++++++++++++--- src/ReC.Domain/Views/RecActionView.cs | 35 +++++++++++++++++++++++++++ src/ReC.Domain/Views/ResultView.cs | 18 ++++++++++++++ 3 files changed, 77 insertions(+), 4 deletions(-) diff --git a/src/ReC.Domain/Views/ProfileView.cs b/src/ReC.Domain/Views/ProfileView.cs index dc2710b..3e61272 100644 --- a/src/ReC.Domain/Views/ProfileView.cs +++ b/src/ReC.Domain/Views/ProfileView.cs @@ -1,4 +1,5 @@ using ReC.Domain.Constants; +using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; namespace ReC.Domain.Views; @@ -8,39 +9,58 @@ public record ProfileView { public virtual IEnumerable? Actions { get; init; } + [Key] + [Column("PROFILE_GUID")] public long Id { get; init; } - + + [Column("ACTIVE")] public bool Active { get; init; } - + + [Column("TYPE_ID")] public ProfileType TypeId { get; init; } - + + [Column("TYPE")] public string? Type { get; init; } - + + [Column("MANDANTOR")] public string? Mandantor { get; init; } + [Column("PROFILE_NAME")] public string? ProfileName { get; init; } + [Column("DESCRIPTION")] public string? Description { get; init; } + [Column("LOG_LEVEL_ID")] public byte LogLevelId { get; init; } + [Column("LOG_LEVEL")] public string? LogLevel { get; init; } + [Column("LANGUAGE_ID")] public short LanguageId { get; init; } + [Column("LANGUAGE")] public string? Language { get; init; } + [Column("ADDED_WHO")] public string? AddedWho { get; init; } + [Column("ADDED_WHEN")] public DateTime AddedWhen { get; init; } + [Column("CHANGED_WHO")] public string? ChangedWho { get; init; } + [Column("CHANGED_WHEN")] public DateTime? ChangedWhen { get; init; } + [Column("FIRST_RUN")] public DateTime? FirstRun { get; init; } + [Column("LAST_RUN")] public DateTime? LastRun { get; init; } + [Column("LAST_RESULT")] public string? LastResult { get; init; } } \ No newline at end of file diff --git a/src/ReC.Domain/Views/RecActionView.cs b/src/ReC.Domain/Views/RecActionView.cs index ec7d670..585b124 100644 --- a/src/ReC.Domain/Views/RecActionView.cs +++ b/src/ReC.Domain/Views/RecActionView.cs @@ -1,4 +1,5 @@ using ReC.Domain.Constants; +using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; namespace ReC.Domain.Views; @@ -16,72 +17,106 @@ public class RecActionView { public virtual IEnumerable? Results { get; set; } + [Key] + [Column("ACTION_GUID")] public required long Id { get; set; } + [Column("PROFILE_ID")] public long? ProfileId { get; set; } [ForeignKey("ProfileId")] public ProfileView? Profile { get; set; } + [Column("PROFILE_NAME")] public string? ProfileName { get; set; } + [Column("PROFILE_TYPE_ID")] public ProfileType? ProfileType { get; set; } + [Column("SEQUENCE")] public byte? Sequence { get; set; } + [Column("ENDPOINT_ID")] public long? EndpointId { get; set; } + [Column("ENDPOINT_URI")] public string? EndpointUri { get; set; } + [Column("ENDPOINT_AUTH_ID")] public long? EndpointAuthId { get; set; } + [Column("ENDPOINT_AUTH_TYPE_ID")] public EndpointAuthType? EndpointAuthType { get; set; } + [Column("ENDPOINT_AUTH_TYPE")] public string? EndpointAuthTypeName { get; set; } + [Column("ENDPOINT_AUTH_API_KEY")] public string? EndpointAuthApiKey { get; set; } + [Column("ENDPOINT_AUTH_API_VALUE")] public string? EndpointAuthApiValue { get; set; } + [Column("ENDPOINT_AUTH_API_KEY_ADD_TO_ID")] public ApiKeyLocation? EndpointAuthApiKeyAddTo { get; set; } + [Column("ENDPOINT_AUTH_API_KEY_ADD_TO")] public string? EndpointAuthApiKeyAddToName { get; set; } + [Column("ENDPOINT_AUTH_TOKEN")] public string? EndpointAuthToken { get; set; } + [Column("ENDPOINT_AUTH_USERNAME")] public string? EndpointAuthUsername { get; set; } + [Column("ENDPOINT_AUTH_PASSWORD")] public string? EndpointAuthPassword { get; set; } + [Column("ENDPOINT_AUTH_DOMAIN")] public string? EndpointAuthDomain { get; set; } + [Column("ENDPOINT_AUTH_WORKSTATION")] public string? EndpointAuthWorkstation { get; set; } + [Column("ENDPOINT_PARAMS_ID")] public short? EndpointParamsId { get; set; } + [Column("SQL_CONNECTION_ID")] public short? SqlConnectionId { get; set; } + [Column("SQL_CONNECTION_SERVER")] public string? SqlConnectionServer { get; set; } + [Column("SQL_CONNECTION_DB")] public string? SqlConnectionDb { get; set; } + [Column("SQL_CONNECTION_USERNAME")] public string? SqlConnectionUsername { get; set; } + [Column("SQL_CONNECTION_PASSWORD")] public string? SqlConnectionPassword { get; set; } + [Column("REST_TYPE_ID")] public RestType? RestType { get; set; } + [Column("REST_TYPE")] public string? RestTypeName { get; set; } + [Column("PREPROCESSING_QUERY")] public string? PreprocessingQuery { get; set; } + [Column("HEADER_QUERY")] public string? HeaderQuery { get; set; } + [Column("BODY_QUERY")] public string? BodyQuery { get; set; } + [Column("POSTPROCESSING_QUERY")] public string? PostprocessingQuery { get; set; } + [Column("ERROR_ACTION_ID")] public ErrorAction? ErrorAction { get; set; } + [Column("ERROR_ACTION")] public string? ErrorActionName { get; set; } } \ No newline at end of file diff --git a/src/ReC.Domain/Views/ResultView.cs b/src/ReC.Domain/Views/ResultView.cs index 4a27c11..2b1ce16 100644 --- a/src/ReC.Domain/Views/ResultView.cs +++ b/src/ReC.Domain/Views/ResultView.cs @@ -1,4 +1,5 @@ using ReC.Domain.Constants; +using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; namespace ReC.Domain.Views; @@ -6,39 +7,56 @@ namespace ReC.Domain.Views; [Table("VWREC_RESULT", Schema = "dbo")] public class ResultView { + [Key] + [Column("RESULT_GUID")] public long Id { get; set; } + [Column("ACTION_ID")] public long? ActionId { get; set; } public RecActionView? Action { get; set; } + [Column("PROFILE_ID")] public long? ProfileId { get; set; } public ProfileView? Profile { get; set; } + [Column("PROFILE_NAME")] public string? ProfileName { get; set; } + [Column("STATUS_ID")] public short? StatusCode { get; set; } + [Column("STATUS")] public string? StatusName { get; set; } + [Column("RESULT_TYPE_ID")] public ResultType? Type { get; set; } + [Column("RESULT_TYPE")] public string? TypeName { get; set; } + [Column("RESULT_HEADER")] public string? Header { get; set; } + [Column("RESULT_BODY")] public string? Body { get; set; } + [Column("RESULT_INFO")] public string? Info { get; set; } + [Column("RESULT_ERROR")] public string? Error { get; set; } + [Column("ADDED_WHO")] public string? AddedWho { get; set; } + [Column("ADDED_WHEN")] public DateTime? AddedWhen { get; set; } + [Column("CHANGED_WHO")] public string? ChangedWho { get; set; } + [Column("CHANGED_WHEN")] public DateTime? ChangedWhen { get; set; } } \ No newline at end of file