diff --git a/src/ReC.API/appsettings.DbModel.json b/src/ReC.API/appsettings.DbModel.json index cc14081..0ae3154 100644 --- a/src/ReC.API/appsettings.DbModel.json +++ b/src/ReC.API/appsettings.DbModel.json @@ -1,98 +1,106 @@ { "DbModel": { - "RecActionView": { - "View": { + "Entities": { + "RecActionView": { "Name": "VWREC_ACTION", - "Schema": "dbo" + "Schema": "dbo", + "ColumnMappings": { + "Id": "ACTION_GUID", + "ProfileId": "PROFILE_ID", + "ProfileName": "PROFILE_NAME", + "ProfileType": "PROFILE_TYPE_ID", + "Sequence": "SEQUENCE", + "EndpointId": "ENDPOINT_ID", + "EndpointUri": "ENDPOINT_URI", + "EndpointAuthId": "ENDPOINT_AUTH_ID", + "EndpointAuthType": "ENDPOINT_AUTH_TYPE_ID", + "EndpointAuthTypeName": "ENDPOINT_AUTH_TYPE", + "EndpointAuthApiKey": "ENDPOINT_AUTH_API_KEY", + "EndpointAuthApiValue": "ENDPOINT_AUTH_API_VALUE", + "EndpointAuthApiKeyAddTo": "ENDPOINT_AUTH_API_KEY_ADD_TO_ID", + "EndpointAuthApiKeyAddToName": "ENDPOINT_AUTH_API_KEY_ADD_TO", + "EndpointAuthToken": "ENDPOINT_AUTH_TOKEN", + "EndpointAuthUsername": "ENDPOINT_AUTH_USERNAME", + "EndpointAuthPassword": "ENDPOINT_AUTH_PASSWORD", + "EndpointAuthDomain": "ENDPOINT_AUTH_DOMAIN", + "EndpointAuthWorkstation": "ENDPOINT_AUTH_WORKSTATION", + "EndpointParamsId": "ENDPOINT_PARAMS_ID", + "SqlConnectionId": "SQL_CONNECTION_ID", + "SqlConnectionServer": "SQL_CONNECTION_SERVER", + "SqlConnectionDb": "SQL_CONNECTION_DB", + "SqlConnectionUsername": "SQL_CONNECTION_USERNAME", + "SqlConnectionPassword": "SQL_CONNECTION_PASSWORD", + "RestType": "REST_TYPE_ID", + "RestTypeName": "REST_TYPE", + "PreprocessingQuery": "PREPROCESSING_QUERY", + "HeaderQuery": "HEADER_QUERY", + "BodyQuery": "BODY_QUERY", + "PostprocessingQuery": "POSTPROCESSING_QUERY", + "ErrorAction": "ERROR_ACTION_ID", + "ErrorActionName": "ERROR_ACTION" + } }, - "Id": "ACTION_GUID", - "ProfileId": "PROFILE_ID", - "ProfileName": "PROFILE_NAME", - "ProfileType": "PROFILE_TYPE_ID", - "Sequence": "SEQUENCE", - "EndpointId": "ENDPOINT_ID", - "EndpointUri": "ENDPOINT_URI", - "EndpointAuthId": "ENDPOINT_AUTH_ID", - "EndpointAuthType": "ENDPOINT_AUTH_TYPE_ID", - "EndpointAuthTypeName": "ENDPOINT_AUTH_TYPE", - "EndpointAuthApiKey": "ENDPOINT_AUTH_API_KEY", - "EndpointAuthApiValue": "ENDPOINT_AUTH_API_VALUE", - "EndpointAuthApiKeyAddTo": "ENDPOINT_AUTH_API_KEY_ADD_TO_ID", - "EndpointAuthApiKeyAddToName": "ENDPOINT_AUTH_API_KEY_ADD_TO", - "EndpointAuthToken": "ENDPOINT_AUTH_TOKEN", - "EndpointAuthUsername": "ENDPOINT_AUTH_USERNAME", - "EndpointAuthPassword": "ENDPOINT_AUTH_PASSWORD", - "EndpointAuthDomain": "ENDPOINT_AUTH_DOMAIN", - "EndpointAuthWorkstation": "ENDPOINT_AUTH_WORKSTATION", - "EndpointParamsId": "ENDPOINT_PARAMS_ID", - "SqlConnectionId": "SQL_CONNECTION_ID", - "SqlConnectionServer": "SQL_CONNECTION_SERVER", - "SqlConnectionDb": "SQL_CONNECTION_DB", - "SqlConnectionUsername": "SQL_CONNECTION_USERNAME", - "SqlConnectionPassword": "SQL_CONNECTION_PASSWORD", - "RestType": "REST_TYPE_ID", - "RestTypeName": "REST_TYPE", - "PreprocessingQuery": "PREPROCESSING_QUERY", - "HeaderQuery": "HEADER_QUERY", - "BodyQuery": "BODY_QUERY", - "PostprocessingQuery": "POSTPROCESSING_QUERY", - "ErrorAction": "ERROR_ACTION_ID", - "ErrorActionName": "ERROR_ACTION" - }, - "ProfileView": { - "View": { + "ProfileView": { "Name": "VWREC_PROFILE", - "Schema": "dbo" + "Schema": "dbo", + "ColumnMappings": { + "Id": "PROFILE_GUID", + "Active": "ACTIVE", + "TypeId": "TYPE_ID", + "Type": "TYPE", + "Mandantor": "MANDANTOR", + "ProfileName": "PROFILE_NAME", + "Description": "DESCRIPTION", + "LogLevelId": "LOG_LEVEL_ID", + "LogLevel": "LOG_LEVEL", + "LanguageId": "LANGUAGE_ID", + "Language": "LANGUAGE", + "AddedWho": "ADDED_WHO", + "AddedWhen": "ADDED_WHEN", + "ChangedWho": "CHANGED_WHO", + "ChangedWhen": "CHANGED_WHEN", + "FirstRun": "FIRST_RUN", + "LastRun": "LAST_RUN", + "LastResult": "LAST_RESULT" + } }, - "Id": "PROFILE_GUID", - "Active": "ACTIVE", - "TypeId": "TYPE_ID", - "Type": "TYPE", - "Mandantor": "MANDANTOR", - "ProfileName": "PROFILE_NAME", - "Description": "DESCRIPTION", - "LogLevelId": "LOG_LEVEL_ID", - "LogLevel": "LOG_LEVEL", - "LanguageId": "LANGUAGE_ID", - "Language": "LANGUAGE", - "AddedWho": "ADDED_WHO", - "AddedWhen": "ADDED_WHEN", - "ChangedWho": "CHANGED_WHO", - "ChangedWhen": "CHANGED_WHEN", - "FirstRun": "FIRST_RUN", - "LastRun": "LAST_RUN", - "LastResult": "LAST_RESULT" - }, - "ResultView": { - "View": { + "ResultView": { "Name": "VWREC_RESULT", - "Schema": "dbo" + "Schema": "dbo", + "ColumnMappings": { + "Id": "RESULT_GUID", + "ActionId": "ACTION_ID", + "ProfileId": "PROFILE_ID", + "ProfileName": "PROFILE_NAME", + "StatusCode": "STATUS_ID", + "StatusName": "STATUS", + "Type": "RESULT_TYPE_ID", + "TypeName": "RESULT_TYPE", + "Header": "RESULT_HEADER", + "Body": "RESULT_BODY", + "Info": "RESULT_INFO", + "Error": "RESULT_ERROR", + "AddedWho": "ADDED_WHO", + "AddedWhen": "ADDED_WHEN", + "ChangedWho": "CHANGED_WHO", + "ChangedWhen": "CHANGED_WHEN" + } }, - "Id": "RESULT_GUID", - "ActionId": "ACTION_ID", - "ProfileId": "PROFILE_ID", - "ProfileName": "PROFILE_NAME", - "StatusCode": "STATUS_ID", - "StatusName": "STATUS", - "Type": "RESULT_TYPE_ID", - "TypeName": "RESULT_TYPE", - "Header": "RESULT_HEADER", - "Body": "RESULT_BODY", - "Info": "RESULT_INFO", - "Error": "RESULT_ERROR", - "AddedWho": "ADDED_WHO", - "AddedWhen": "ADDED_WHEN", - "ChangedWho": "CHANGED_WHO", - "ChangedWhen": "CHANGED_WHEN" - }, - "HeaderQueryResult": { - "RawHeader": "REQUEST_HEADER" - }, - "BodyQueryResult": { - "RawBody": "REQUEST_BODY" - }, - "InsertObjectResult": { - "NewObjectId": "oGUID" + "HeaderQueryResult": { + "ColumnMappings": { + "RawHeader": "REQUEST_HEADER" + } + }, + "BodyQueryResult": { + "ColumnMappings": { + "RawBody": "REQUEST_BODY" + } + }, + "InsertObjectResult": { + "ColumnMappings": { + "NewObjectId": "oGUID" + } + } } } } \ No newline at end of file diff --git a/src/ReC.Infrastructure/Exceptions/DbModelConfigurationException.cs b/src/ReC.Application/Common/Exceptions/DbModelConfigurationException.cs similarity index 50% rename from src/ReC.Infrastructure/Exceptions/DbModelConfigurationException.cs rename to src/ReC.Application/Common/Exceptions/DbModelConfigurationException.cs index 20cae2b..cb678b3 100644 --- a/src/ReC.Infrastructure/Exceptions/DbModelConfigurationException.cs +++ b/src/ReC.Application/Common/Exceptions/DbModelConfigurationException.cs @@ -1,12 +1,8 @@ -namespace ReC.Infrastructure.Exceptions; +namespace ReC.Application.Common.Exceptions; public class DbModelConfigurationException : Exception { - public DbModelConfigurationException(string message) : base(message) - { - } + public DbModelConfigurationException() { } - public DbModelConfigurationException() - { - } -} \ No newline at end of file + public DbModelConfigurationException(string message) : base(message) { } +} diff --git a/src/ReC.Application/Common/Options/DbModel/BodyQueryResultOptions.cs b/src/ReC.Application/Common/Options/DbModel/BodyQueryResultOptions.cs deleted file mode 100644 index 827d2d3..0000000 --- a/src/ReC.Application/Common/Options/DbModel/BodyQueryResultOptions.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace ReC.Application.Common.Options.DbModel; - -public class BodyQueryResultOptions -{ - public string RawBody { get; set; } = "REQUEST_BODY"; -} diff --git a/src/ReC.Application/Common/Options/DbModel/DbModelOptions.cs b/src/ReC.Application/Common/Options/DbModel/DbModelOptions.cs index 6b39a58..ff3874d 100644 --- a/src/ReC.Application/Common/Options/DbModel/DbModelOptions.cs +++ b/src/ReC.Application/Common/Options/DbModel/DbModelOptions.cs @@ -2,15 +2,5 @@ namespace ReC.Application.Common.Options.DbModel; public class DbModelOptions { - public RecActionViewOptions RecActionView { get; set; } = new(); - - public ProfileViewOptions ProfileView { get; set; } = new(); - - public ResultViewOptions ResultView { get; set; } = new(); - - public HeaderQueryResultOptions HeaderQueryResult { get; set; } = new(); - - public BodyQueryResultOptions BodyQueryResult { get; set; } = new(); - - public InsertObjectResultOptions InsertObjectResult { get; set; } = new(); + public Dictionary Entities { get; set; } = []; } diff --git a/src/ReC.Application/Common/Options/DbModel/DbModelOptionsExtensions.cs b/src/ReC.Application/Common/Options/DbModel/DbModelOptionsExtensions.cs new file mode 100644 index 0000000..e16a68a --- /dev/null +++ b/src/ReC.Application/Common/Options/DbModel/DbModelOptionsExtensions.cs @@ -0,0 +1,25 @@ +using ReC.Application.Common.Exceptions; + +namespace ReC.Application.Common.Options.DbModel; + +public static class DbModelOptionsExtensions +{ + public static EntityOptions GetEntity(this DbModelOptions options, string entityName) + { + if (options.Entities.TryGetValue(entityName, out var entity)) + return entity; + + throw new DbModelConfigurationException( + $"Entity '{entityName}' is not configured in DbModel options."); + } + + public static string GetColumn(this EntityOptions entity, string entityName, string propertyName) + { + if (entity.ColumnMappings.TryGetValue(propertyName, out var columnName)) + return columnName; + + var viewDisplay = entity.Name ?? entityName; + throw new DbModelConfigurationException( + $"Column mapping for property '{propertyName}' is not configured for entity '{viewDisplay}'."); + } +} diff --git a/src/ReC.Application/Common/Options/DbModel/EntityOptions.cs b/src/ReC.Application/Common/Options/DbModel/EntityOptions.cs new file mode 100644 index 0000000..6b551d0 --- /dev/null +++ b/src/ReC.Application/Common/Options/DbModel/EntityOptions.cs @@ -0,0 +1,10 @@ +namespace ReC.Application.Common.Options.DbModel; + +public class EntityOptions +{ + public string? Name { get; set; } + + public string Schema { get; set; } = "dbo"; + + public Dictionary ColumnMappings { get; set; } = []; +} diff --git a/src/ReC.Application/Common/Options/DbModel/HeaderQueryResultOptions.cs b/src/ReC.Application/Common/Options/DbModel/HeaderQueryResultOptions.cs deleted file mode 100644 index df3ffd6..0000000 --- a/src/ReC.Application/Common/Options/DbModel/HeaderQueryResultOptions.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace ReC.Application.Common.Options.DbModel; - -public class HeaderQueryResultOptions -{ - public string RawHeader { get; set; } = "REQUEST_HEADER"; -} diff --git a/src/ReC.Application/Common/Options/DbModel/InsertObjectResultOptions.cs b/src/ReC.Application/Common/Options/DbModel/InsertObjectResultOptions.cs deleted file mode 100644 index 8163d21..0000000 --- a/src/ReC.Application/Common/Options/DbModel/InsertObjectResultOptions.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace ReC.Application.Common.Options.DbModel; - -public class InsertObjectResultOptions -{ - public string NewObjectId { get; set; } = "oGUID"; -} diff --git a/src/ReC.Application/Common/Options/DbModel/ProfileViewOptions.cs b/src/ReC.Application/Common/Options/DbModel/ProfileViewOptions.cs deleted file mode 100644 index aef5c8a..0000000 --- a/src/ReC.Application/Common/Options/DbModel/ProfileViewOptions.cs +++ /dev/null @@ -1,25 +0,0 @@ -namespace ReC.Application.Common.Options.DbModel; - -public class ProfileViewOptions -{ - public ViewOptions View { get; set; } = new() { Name = "VWREC_PROFILE", Schema = "dbo" }; - - public string Id { get; set; } = "PROFILE_GUID"; - public string Active { get; set; } = "ACTIVE"; - public string TypeId { get; set; } = "TYPE_ID"; - public string Type { get; set; } = "TYPE"; - public string Mandantor { get; set; } = "MANDANTOR"; - public string ProfileName { get; set; } = "PROFILE_NAME"; - public string Description { get; set; } = "DESCRIPTION"; - public string LogLevelId { get; set; } = "LOG_LEVEL_ID"; - public string LogLevel { get; set; } = "LOG_LEVEL"; - public string LanguageId { get; set; } = "LANGUAGE_ID"; - public string Language { get; set; } = "LANGUAGE"; - public string AddedWho { get; set; } = "ADDED_WHO"; - public string AddedWhen { get; set; } = "ADDED_WHEN"; - public string ChangedWho { get; set; } = "CHANGED_WHO"; - public string ChangedWhen { get; set; } = "CHANGED_WHEN"; - public string FirstRun { get; set; } = "FIRST_RUN"; - public string LastRun { get; set; } = "LAST_RUN"; - public string LastResult { get; set; } = "LAST_RESULT"; -} diff --git a/src/ReC.Application/Common/Options/DbModel/RecActionViewOptions.cs b/src/ReC.Application/Common/Options/DbModel/RecActionViewOptions.cs deleted file mode 100644 index 5955461..0000000 --- a/src/ReC.Application/Common/Options/DbModel/RecActionViewOptions.cs +++ /dev/null @@ -1,40 +0,0 @@ -namespace ReC.Application.Common.Options.DbModel; - -public class RecActionViewOptions -{ - public ViewOptions View { get; set; } = new() { Name = "VWREC_ACTION", Schema = "dbo" }; - - public string Id { get; set; } = "ACTION_GUID"; - public string ProfileId { get; set; } = "PROFILE_ID"; - public string ProfileName { get; set; } = "PROFILE_NAME"; - public string ProfileType { get; set; } = "PROFILE_TYPE_ID"; - public string Sequence { get; set; } = "SEQUENCE"; - public string EndpointId { get; set; } = "ENDPOINT_ID"; - public string EndpointUri { get; set; } = "ENDPOINT_URI"; - public string EndpointAuthId { get; set; } = "ENDPOINT_AUTH_ID"; - public string EndpointAuthType { get; set; } = "ENDPOINT_AUTH_TYPE_ID"; - public string EndpointAuthTypeName { get; set; } = "ENDPOINT_AUTH_TYPE"; - public string EndpointAuthApiKey { get; set; } = "ENDPOINT_AUTH_API_KEY"; - public string EndpointAuthApiValue { get; set; } = "ENDPOINT_AUTH_API_VALUE"; - public string EndpointAuthApiKeyAddTo { get; set; } = "ENDPOINT_AUTH_API_KEY_ADD_TO_ID"; - public string EndpointAuthApiKeyAddToName { get; set; } = "ENDPOINT_AUTH_API_KEY_ADD_TO"; - public string EndpointAuthToken { get; set; } = "ENDPOINT_AUTH_TOKEN"; - public string EndpointAuthUsername { get; set; } = "ENDPOINT_AUTH_USERNAME"; - public string EndpointAuthPassword { get; set; } = "ENDPOINT_AUTH_PASSWORD"; - public string EndpointAuthDomain { get; set; } = "ENDPOINT_AUTH_DOMAIN"; - public string EndpointAuthWorkstation { get; set; } = "ENDPOINT_AUTH_WORKSTATION"; - public string EndpointParamsId { get; set; } = "ENDPOINT_PARAMS_ID"; - public string SqlConnectionId { get; set; } = "SQL_CONNECTION_ID"; - public string SqlConnectionServer { get; set; } = "SQL_CONNECTION_SERVER"; - public string SqlConnectionDb { get; set; } = "SQL_CONNECTION_DB"; - public string SqlConnectionUsername { get; set; } = "SQL_CONNECTION_USERNAME"; - public string SqlConnectionPassword { get; set; } = "SQL_CONNECTION_PASSWORD"; - public string RestType { get; set; } = "REST_TYPE_ID"; - public string RestTypeName { get; set; } = "REST_TYPE"; - public string PreprocessingQuery { get; set; } = "PREPROCESSING_QUERY"; - public string HeaderQuery { get; set; } = "HEADER_QUERY"; - public string BodyQuery { get; set; } = "BODY_QUERY"; - public string PostprocessingQuery { get; set; } = "POSTPROCESSING_QUERY"; - public string ErrorAction { get; set; } = "ERROR_ACTION_ID"; - public string ErrorActionName { get; set; } = "ERROR_ACTION"; -} diff --git a/src/ReC.Application/Common/Options/DbModel/ResultViewOptions.cs b/src/ReC.Application/Common/Options/DbModel/ResultViewOptions.cs deleted file mode 100644 index d147ea0..0000000 --- a/src/ReC.Application/Common/Options/DbModel/ResultViewOptions.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace ReC.Application.Common.Options.DbModel; - -public class ResultViewOptions -{ - public ViewOptions View { get; set; } = new() { Name = "VWREC_RESULT", Schema = "dbo" }; - - public string Id { get; set; } = "RESULT_GUID"; - public string ActionId { get; set; } = "ACTION_ID"; - public string ProfileId { get; set; } = "PROFILE_ID"; - public string ProfileName { get; set; } = "PROFILE_NAME"; - public string StatusCode { get; set; } = "STATUS_ID"; - public string StatusName { get; set; } = "STATUS"; - public string Type { get; set; } = "RESULT_TYPE_ID"; - public string TypeName { get; set; } = "RESULT_TYPE"; - public string Header { get; set; } = "RESULT_HEADER"; - public string Body { get; set; } = "RESULT_BODY"; - public string Info { get; set; } = "RESULT_INFO"; - public string Error { get; set; } = "RESULT_ERROR"; - public string AddedWho { get; set; } = "ADDED_WHO"; - public string AddedWhen { get; set; } = "ADDED_WHEN"; - public string ChangedWho { get; set; } = "CHANGED_WHO"; - public string ChangedWhen { get; set; } = "CHANGED_WHEN"; -} diff --git a/src/ReC.Application/Common/Options/DbModel/ViewOptions.cs b/src/ReC.Application/Common/Options/DbModel/ViewOptions.cs deleted file mode 100644 index ebd76fc..0000000 --- a/src/ReC.Application/Common/Options/DbModel/ViewOptions.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace ReC.Application.Common.Options.DbModel; - -public class ViewOptions -{ - public string Name { get; set; } = null!; - - public string Schema { get; set; } = "dbo"; -} diff --git a/src/ReC.Infrastructure/RecDbContext.cs b/src/ReC.Infrastructure/RecDbContext.cs index dc8c734..641b0cf 100644 --- a/src/ReC.Infrastructure/RecDbContext.cs +++ b/src/ReC.Infrastructure/RecDbContext.cs @@ -29,98 +29,121 @@ public class RecDbContext(DbContextOptions options, IOptions(b => { - b.ToView(actionOpt.View.Name, actionOpt.View.Schema); + b.ToView(opt.Name, opt.Schema); b.HasKey(e => e.Id); - b.Property(e => e.Id).HasColumnName(actionOpt.Id); - b.Property(e => e.ProfileId).HasColumnName(actionOpt.ProfileId); - b.Property(e => e.ProfileName).HasColumnName(actionOpt.ProfileName); - b.Property(e => e.ProfileType).HasColumnName(actionOpt.ProfileType); - b.Property(e => e.Sequence).HasColumnName(actionOpt.Sequence); - b.Property(e => e.EndpointId).HasColumnName(actionOpt.EndpointId); - b.Property(e => e.EndpointUri).HasColumnName(actionOpt.EndpointUri); - b.Property(e => e.EndpointAuthId).HasColumnName(actionOpt.EndpointAuthId); - b.Property(e => e.EndpointAuthType).HasColumnName(actionOpt.EndpointAuthType); - b.Property(e => e.EndpointAuthTypeName).HasColumnName(actionOpt.EndpointAuthTypeName); - b.Property(e => e.EndpointAuthApiKey).HasColumnName(actionOpt.EndpointAuthApiKey); - b.Property(e => e.EndpointAuthApiValue).HasColumnName(actionOpt.EndpointAuthApiValue); - b.Property(e => e.EndpointAuthApiKeyAddTo).HasColumnName(actionOpt.EndpointAuthApiKeyAddTo); - b.Property(e => e.EndpointAuthApiKeyAddToName).HasColumnName(actionOpt.EndpointAuthApiKeyAddToName); - b.Property(e => e.EndpointAuthToken).HasColumnName(actionOpt.EndpointAuthToken); - b.Property(e => e.EndpointAuthUsername).HasColumnName(actionOpt.EndpointAuthUsername); - b.Property(e => e.EndpointAuthPassword).HasColumnName(actionOpt.EndpointAuthPassword); - b.Property(e => e.EndpointAuthDomain).HasColumnName(actionOpt.EndpointAuthDomain); - b.Property(e => e.EndpointAuthWorkstation).HasColumnName(actionOpt.EndpointAuthWorkstation); - b.Property(e => e.EndpointParamsId).HasColumnName(actionOpt.EndpointParamsId); - b.Property(e => e.SqlConnectionId).HasColumnName(actionOpt.SqlConnectionId); - b.Property(e => e.SqlConnectionServer).HasColumnName(actionOpt.SqlConnectionServer); - b.Property(e => e.SqlConnectionDb).HasColumnName(actionOpt.SqlConnectionDb); - b.Property(e => e.SqlConnectionUsername).HasColumnName(actionOpt.SqlConnectionUsername); - b.Property(e => e.SqlConnectionPassword).HasColumnName(actionOpt.SqlConnectionPassword); - b.Property(e => e.RestType).HasColumnName(actionOpt.RestType); - b.Property(e => e.RestTypeName).HasColumnName(actionOpt.RestTypeName); - b.Property(e => e.PreprocessingQuery).HasColumnName(actionOpt.PreprocessingQuery); - b.Property(e => e.HeaderQuery).HasColumnName(actionOpt.HeaderQuery); - b.Property(e => e.BodyQuery).HasColumnName(actionOpt.BodyQuery); - b.Property(e => e.PostprocessingQuery).HasColumnName(actionOpt.PostprocessingQuery); - b.Property(e => e.ErrorAction).HasColumnName(actionOpt.ErrorAction); - b.Property(e => e.ErrorActionName).HasColumnName(actionOpt.ErrorActionName); + b.Property(e => e.Id).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.Id))); + b.Property(e => e.ProfileId).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.ProfileId))); + b.Property(e => e.ProfileName).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.ProfileName))); + b.Property(e => e.ProfileType).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.ProfileType))); + b.Property(e => e.Sequence).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.Sequence))); + b.Property(e => e.EndpointId).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.EndpointId))); + b.Property(e => e.EndpointUri).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.EndpointUri))); + b.Property(e => e.EndpointAuthId).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.EndpointAuthId))); + b.Property(e => e.EndpointAuthType).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.EndpointAuthType))); + b.Property(e => e.EndpointAuthTypeName).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.EndpointAuthTypeName))); + b.Property(e => e.EndpointAuthApiKey).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.EndpointAuthApiKey))); + b.Property(e => e.EndpointAuthApiValue).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.EndpointAuthApiValue))); + b.Property(e => e.EndpointAuthApiKeyAddTo).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.EndpointAuthApiKeyAddTo))); + b.Property(e => e.EndpointAuthApiKeyAddToName).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.EndpointAuthApiKeyAddToName))); + b.Property(e => e.EndpointAuthToken).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.EndpointAuthToken))); + b.Property(e => e.EndpointAuthUsername).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.EndpointAuthUsername))); + b.Property(e => e.EndpointAuthPassword).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.EndpointAuthPassword))); + b.Property(e => e.EndpointAuthDomain).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.EndpointAuthDomain))); + b.Property(e => e.EndpointAuthWorkstation).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.EndpointAuthWorkstation))); + b.Property(e => e.EndpointParamsId).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.EndpointParamsId))); + b.Property(e => e.SqlConnectionId).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.SqlConnectionId))); + b.Property(e => e.SqlConnectionServer).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.SqlConnectionServer))); + b.Property(e => e.SqlConnectionDb).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.SqlConnectionDb))); + b.Property(e => e.SqlConnectionUsername).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.SqlConnectionUsername))); + b.Property(e => e.SqlConnectionPassword).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.SqlConnectionPassword))); + b.Property(e => e.RestType).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.RestType))); + b.Property(e => e.RestTypeName).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.RestTypeName))); + b.Property(e => e.PreprocessingQuery).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.PreprocessingQuery))); + b.Property(e => e.HeaderQuery).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.HeaderQuery))); + b.Property(e => e.BodyQuery).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.BodyQuery))); + b.Property(e => e.PostprocessingQuery).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.PostprocessingQuery))); + b.Property(e => e.ErrorAction).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.ErrorAction))); + b.Property(e => e.ErrorActionName).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.ErrorActionName))); b.HasMany(e => e.Results) .WithOne(r => r.Action) .HasForeignKey(r => r.ActionId); }); + } + + private void ConfigureProfileView(ModelBuilder modelBuilder) + { + const string entityName = nameof(ProfileView); + var opt = _dbModelOptions.GetEntity(entityName); - var profileOpt = _dbModelOptions.ProfileView; modelBuilder.Entity(b => { - b.ToView(profileOpt.View.Name, profileOpt.View.Schema); + b.ToView(opt.Name, opt.Schema); b.HasKey(e => e.Id); - b.Property(e => e.Id).HasColumnName(profileOpt.Id); - b.Property(e => e.Active).HasColumnName(profileOpt.Active); - b.Property(e => e.TypeId).HasColumnName(profileOpt.TypeId); - b.Property(e => e.Type).HasColumnName(profileOpt.Type); - b.Property(e => e.Mandantor).HasColumnName(profileOpt.Mandantor); - b.Property(e => e.ProfileName).HasColumnName(profileOpt.ProfileName); - b.Property(e => e.Description).HasColumnName(profileOpt.Description); - b.Property(e => e.LogLevelId).HasColumnName(profileOpt.LogLevelId); - b.Property(e => e.LogLevel).HasColumnName(profileOpt.LogLevel); - b.Property(e => e.LanguageId).HasColumnName(profileOpt.LanguageId); - b.Property(e => e.Language).HasColumnName(profileOpt.Language); - b.Property(e => e.AddedWho).HasColumnName(profileOpt.AddedWho); - b.Property(e => e.AddedWhen).HasColumnName(profileOpt.AddedWhen); - b.Property(e => e.ChangedWho).HasColumnName(profileOpt.ChangedWho); - b.Property(e => e.ChangedWhen).HasColumnName(profileOpt.ChangedWhen); - b.Property(e => e.FirstRun).HasColumnName(profileOpt.FirstRun); - b.Property(e => e.LastRun).HasColumnName(profileOpt.LastRun); - b.Property(e => e.LastResult).HasColumnName(profileOpt.LastResult); - }); - var resultOpt = _dbModelOptions.ResultView; + b.Property(e => e.Id).HasColumnName(opt.GetColumn(entityName, nameof(ProfileView.Id))); + b.Property(e => e.Active).HasColumnName(opt.GetColumn(entityName, nameof(ProfileView.Active))); + b.Property(e => e.TypeId).HasColumnName(opt.GetColumn(entityName, nameof(ProfileView.TypeId))); + b.Property(e => e.Type).HasColumnName(opt.GetColumn(entityName, nameof(ProfileView.Type))); + b.Property(e => e.Mandantor).HasColumnName(opt.GetColumn(entityName, nameof(ProfileView.Mandantor))); + b.Property(e => e.ProfileName).HasColumnName(opt.GetColumn(entityName, nameof(ProfileView.ProfileName))); + b.Property(e => e.Description).HasColumnName(opt.GetColumn(entityName, nameof(ProfileView.Description))); + b.Property(e => e.LogLevelId).HasColumnName(opt.GetColumn(entityName, nameof(ProfileView.LogLevelId))); + b.Property(e => e.LogLevel).HasColumnName(opt.GetColumn(entityName, nameof(ProfileView.LogLevel))); + b.Property(e => e.LanguageId).HasColumnName(opt.GetColumn(entityName, nameof(ProfileView.LanguageId))); + b.Property(e => e.Language).HasColumnName(opt.GetColumn(entityName, nameof(ProfileView.Language))); + b.Property(e => e.AddedWho).HasColumnName(opt.GetColumn(entityName, nameof(ProfileView.AddedWho))); + b.Property(e => e.AddedWhen).HasColumnName(opt.GetColumn(entityName, nameof(ProfileView.AddedWhen))); + b.Property(e => e.ChangedWho).HasColumnName(opt.GetColumn(entityName, nameof(ProfileView.ChangedWho))); + b.Property(e => e.ChangedWhen).HasColumnName(opt.GetColumn(entityName, nameof(ProfileView.ChangedWhen))); + b.Property(e => e.FirstRun).HasColumnName(opt.GetColumn(entityName, nameof(ProfileView.FirstRun))); + b.Property(e => e.LastRun).HasColumnName(opt.GetColumn(entityName, nameof(ProfileView.LastRun))); + b.Property(e => e.LastResult).HasColumnName(opt.GetColumn(entityName, nameof(ProfileView.LastResult))); + }); + } + + private void ConfigureResultView(ModelBuilder modelBuilder) + { + const string entityName = nameof(ResultView); + var opt = _dbModelOptions.GetEntity(entityName); + modelBuilder.Entity(b => { - b.ToView(resultOpt.View.Name, resultOpt.View.Schema); + b.ToView(opt.Name, opt.Schema); b.HasKey(e => e.Id); - b.Property(e => e.Id).HasColumnName(resultOpt.Id); - b.Property(e => e.ActionId).HasColumnName(resultOpt.ActionId); - b.Property(e => e.ProfileId).HasColumnName(resultOpt.ProfileId); - b.Property(e => e.ProfileName).HasColumnName(resultOpt.ProfileName); - b.Property(e => e.StatusCode).HasColumnName(resultOpt.StatusCode); - b.Property(e => e.StatusName).HasColumnName(resultOpt.StatusName); - b.Property(e => e.Type).HasColumnName(resultOpt.Type); - b.Property(e => e.TypeName).HasColumnName(resultOpt.TypeName); - b.Property(e => e.Header).HasColumnName(resultOpt.Header); - b.Property(e => e.Body).HasColumnName(resultOpt.Body); - b.Property(e => e.Info).HasColumnName(resultOpt.Info); - b.Property(e => e.Error).HasColumnName(resultOpt.Error); - b.Property(e => e.AddedWho).HasColumnName(resultOpt.AddedWho); - b.Property(e => e.AddedWhen).HasColumnName(resultOpt.AddedWhen); - b.Property(e => e.ChangedWho).HasColumnName(resultOpt.ChangedWho); - b.Property(e => e.ChangedWhen).HasColumnName(resultOpt.ChangedWhen); + b.Property(e => e.Id).HasColumnName(opt.GetColumn(entityName, nameof(ResultView.Id))); + b.Property(e => e.ActionId).HasColumnName(opt.GetColumn(entityName, nameof(ResultView.ActionId))); + b.Property(e => e.ProfileId).HasColumnName(opt.GetColumn(entityName, nameof(ResultView.ProfileId))); + b.Property(e => e.ProfileName).HasColumnName(opt.GetColumn(entityName, nameof(ResultView.ProfileName))); + b.Property(e => e.StatusCode).HasColumnName(opt.GetColumn(entityName, nameof(ResultView.StatusCode))); + b.Property(e => e.StatusName).HasColumnName(opt.GetColumn(entityName, nameof(ResultView.StatusName))); + b.Property(e => e.Type).HasColumnName(opt.GetColumn(entityName, nameof(ResultView.Type))); + b.Property(e => e.TypeName).HasColumnName(opt.GetColumn(entityName, nameof(ResultView.TypeName))); + b.Property(e => e.Header).HasColumnName(opt.GetColumn(entityName, nameof(ResultView.Header))); + b.Property(e => e.Body).HasColumnName(opt.GetColumn(entityName, nameof(ResultView.Body))); + b.Property(e => e.Info).HasColumnName(opt.GetColumn(entityName, nameof(ResultView.Info))); + b.Property(e => e.Error).HasColumnName(opt.GetColumn(entityName, nameof(ResultView.Error))); + b.Property(e => e.AddedWho).HasColumnName(opt.GetColumn(entityName, nameof(ResultView.AddedWho))); + b.Property(e => e.AddedWhen).HasColumnName(opt.GetColumn(entityName, nameof(ResultView.AddedWhen))); + b.Property(e => e.ChangedWho).HasColumnName(opt.GetColumn(entityName, nameof(ResultView.ChangedWho))); + b.Property(e => e.ChangedWhen).HasColumnName(opt.GetColumn(entityName, nameof(ResultView.ChangedWhen))); b.HasOne(r => r.Action) .WithMany(a => a.Results) @@ -130,26 +153,41 @@ public class RecDbContext(DbContextOptions options, IOptions r.ProfileId); }); + } + + private void ConfigureHeaderQueryResult(ModelBuilder modelBuilder) + { + const string entityName = nameof(HeaderQueryResult); + var opt = _dbModelOptions.GetEntity(entityName); - var headerOpt = _dbModelOptions.HeaderQueryResult; modelBuilder.Entity(b => { b.HasNoKey(); - b.Property(e => e.RawHeader).HasColumnName(headerOpt.RawHeader); + b.Property(e => e.RawHeader).HasColumnName(opt.GetColumn(entityName, nameof(HeaderQueryResult.RawHeader))); }); + } + + private void ConfigureBodyQueryResult(ModelBuilder modelBuilder) + { + const string entityName = nameof(BodyQueryResult); + var opt = _dbModelOptions.GetEntity(entityName); - var bodyOpt = _dbModelOptions.BodyQueryResult; modelBuilder.Entity(b => { b.HasNoKey(); - b.Property(e => e.RawBody).HasColumnName(bodyOpt.RawBody); + b.Property(e => e.RawBody).HasColumnName(opt.GetColumn(entityName, nameof(BodyQueryResult.RawBody))); }); + } + + private void ConfigureInsertObjectResult(ModelBuilder modelBuilder) + { + const string entityName = nameof(InsertObjectResult); + var opt = _dbModelOptions.GetEntity(entityName); - var insertOpt = _dbModelOptions.InsertObjectResult; modelBuilder.Entity(b => { b.HasNoKey(); - b.Property(e => e.NewObjectId).HasColumnName(insertOpt.NewObjectId); + b.Property(e => e.NewObjectId).HasColumnName(opt.GetColumn(entityName, nameof(InsertObjectResult.NewObjectId))); }); } } \ No newline at end of file