Refactor DbModel options to use generic entity mapping
Replaces strongly-typed view options classes with a generic EntityOptions class and a dictionary-based configuration for entity-to-view and property-to-column mappings. Updates appsettings.DbModel.json to match the new structure. Refactors RecDbContext to use extension methods for mapping configuration. Removes obsolete options classes and simplifies exception handling for missing mappings. This change improves flexibility and maintainability of database view configuration.
This commit is contained in:
@@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
"DbModel": {
|
"DbModel": {
|
||||||
|
"Entities": {
|
||||||
"RecActionView": {
|
"RecActionView": {
|
||||||
"View": {
|
|
||||||
"Name": "VWREC_ACTION",
|
"Name": "VWREC_ACTION",
|
||||||
"Schema": "dbo"
|
"Schema": "dbo",
|
||||||
},
|
"ColumnMappings": {
|
||||||
"Id": "ACTION_GUID",
|
"Id": "ACTION_GUID",
|
||||||
"ProfileId": "PROFILE_ID",
|
"ProfileId": "PROFILE_ID",
|
||||||
"ProfileName": "PROFILE_NAME",
|
"ProfileName": "PROFILE_NAME",
|
||||||
@@ -38,12 +38,12 @@
|
|||||||
"PostprocessingQuery": "POSTPROCESSING_QUERY",
|
"PostprocessingQuery": "POSTPROCESSING_QUERY",
|
||||||
"ErrorAction": "ERROR_ACTION_ID",
|
"ErrorAction": "ERROR_ACTION_ID",
|
||||||
"ErrorActionName": "ERROR_ACTION"
|
"ErrorActionName": "ERROR_ACTION"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"ProfileView": {
|
"ProfileView": {
|
||||||
"View": {
|
|
||||||
"Name": "VWREC_PROFILE",
|
"Name": "VWREC_PROFILE",
|
||||||
"Schema": "dbo"
|
"Schema": "dbo",
|
||||||
},
|
"ColumnMappings": {
|
||||||
"Id": "PROFILE_GUID",
|
"Id": "PROFILE_GUID",
|
||||||
"Active": "ACTIVE",
|
"Active": "ACTIVE",
|
||||||
"TypeId": "TYPE_ID",
|
"TypeId": "TYPE_ID",
|
||||||
@@ -62,12 +62,12 @@
|
|||||||
"FirstRun": "FIRST_RUN",
|
"FirstRun": "FIRST_RUN",
|
||||||
"LastRun": "LAST_RUN",
|
"LastRun": "LAST_RUN",
|
||||||
"LastResult": "LAST_RESULT"
|
"LastResult": "LAST_RESULT"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"ResultView": {
|
"ResultView": {
|
||||||
"View": {
|
|
||||||
"Name": "VWREC_RESULT",
|
"Name": "VWREC_RESULT",
|
||||||
"Schema": "dbo"
|
"Schema": "dbo",
|
||||||
},
|
"ColumnMappings": {
|
||||||
"Id": "RESULT_GUID",
|
"Id": "RESULT_GUID",
|
||||||
"ActionId": "ACTION_ID",
|
"ActionId": "ACTION_ID",
|
||||||
"ProfileId": "PROFILE_ID",
|
"ProfileId": "PROFILE_ID",
|
||||||
@@ -84,15 +84,23 @@
|
|||||||
"AddedWhen": "ADDED_WHEN",
|
"AddedWhen": "ADDED_WHEN",
|
||||||
"ChangedWho": "CHANGED_WHO",
|
"ChangedWho": "CHANGED_WHO",
|
||||||
"ChangedWhen": "CHANGED_WHEN"
|
"ChangedWhen": "CHANGED_WHEN"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"HeaderQueryResult": {
|
"HeaderQueryResult": {
|
||||||
|
"ColumnMappings": {
|
||||||
"RawHeader": "REQUEST_HEADER"
|
"RawHeader": "REQUEST_HEADER"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"BodyQueryResult": {
|
"BodyQueryResult": {
|
||||||
|
"ColumnMappings": {
|
||||||
"RawBody": "REQUEST_BODY"
|
"RawBody": "REQUEST_BODY"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"InsertObjectResult": {
|
"InsertObjectResult": {
|
||||||
|
"ColumnMappings": {
|
||||||
"NewObjectId": "oGUID"
|
"NewObjectId": "oGUID"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,12 +1,8 @@
|
|||||||
namespace ReC.Infrastructure.Exceptions;
|
namespace ReC.Application.Common.Exceptions;
|
||||||
|
|
||||||
public class DbModelConfigurationException : Exception
|
public class DbModelConfigurationException : Exception
|
||||||
{
|
{
|
||||||
public DbModelConfigurationException(string message) : base(message)
|
public DbModelConfigurationException() { }
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public DbModelConfigurationException()
|
public DbModelConfigurationException(string message) : base(message) { }
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
namespace ReC.Application.Common.Options.DbModel;
|
|
||||||
|
|
||||||
public class BodyQueryResultOptions
|
|
||||||
{
|
|
||||||
public string RawBody { get; set; } = "REQUEST_BODY";
|
|
||||||
}
|
|
||||||
@@ -2,15 +2,5 @@ namespace ReC.Application.Common.Options.DbModel;
|
|||||||
|
|
||||||
public class DbModelOptions
|
public class DbModelOptions
|
||||||
{
|
{
|
||||||
public RecActionViewOptions RecActionView { get; set; } = new();
|
public Dictionary<string, EntityOptions> Entities { get; set; } = [];
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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}'.");
|
||||||
|
}
|
||||||
|
}
|
||||||
10
src/ReC.Application/Common/Options/DbModel/EntityOptions.cs
Normal file
10
src/ReC.Application/Common/Options/DbModel/EntityOptions.cs
Normal file
@@ -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<string, string> ColumnMappings { get; set; } = [];
|
||||||
|
}
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
namespace ReC.Application.Common.Options.DbModel;
|
|
||||||
|
|
||||||
public class HeaderQueryResultOptions
|
|
||||||
{
|
|
||||||
public string RawHeader { get; set; } = "REQUEST_HEADER";
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
namespace ReC.Application.Common.Options.DbModel;
|
|
||||||
|
|
||||||
public class InsertObjectResultOptions
|
|
||||||
{
|
|
||||||
public string NewObjectId { get; set; } = "oGUID";
|
|
||||||
}
|
|
||||||
@@ -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";
|
|
||||||
}
|
|
||||||
@@ -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";
|
|
||||||
}
|
|
||||||
@@ -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";
|
|
||||||
}
|
|
||||||
@@ -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";
|
|
||||||
}
|
|
||||||
@@ -29,98 +29,121 @@ public class RecDbContext(DbContextOptions<RecDbContext> options, IOptions<DbMod
|
|||||||
{
|
{
|
||||||
base.OnModelCreating(modelBuilder);
|
base.OnModelCreating(modelBuilder);
|
||||||
|
|
||||||
var actionOpt = _dbModelOptions.RecActionView;
|
ConfigureRecActionView(modelBuilder);
|
||||||
|
ConfigureProfileView(modelBuilder);
|
||||||
|
ConfigureResultView(modelBuilder);
|
||||||
|
ConfigureHeaderQueryResult(modelBuilder);
|
||||||
|
ConfigureBodyQueryResult(modelBuilder);
|
||||||
|
ConfigureInsertObjectResult(modelBuilder);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ConfigureRecActionView(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
const string entityName = nameof(RecActionView);
|
||||||
|
var opt = _dbModelOptions.GetEntity(entityName);
|
||||||
|
|
||||||
modelBuilder.Entity<RecActionView>(b =>
|
modelBuilder.Entity<RecActionView>(b =>
|
||||||
{
|
{
|
||||||
b.ToView(actionOpt.View.Name, actionOpt.View.Schema);
|
b.ToView(opt.Name, opt.Schema);
|
||||||
b.HasKey(e => e.Id);
|
b.HasKey(e => e.Id);
|
||||||
|
|
||||||
b.Property(e => e.Id).HasColumnName(actionOpt.Id);
|
b.Property(e => e.Id).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.Id)));
|
||||||
b.Property(e => e.ProfileId).HasColumnName(actionOpt.ProfileId);
|
b.Property(e => e.ProfileId).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.ProfileId)));
|
||||||
b.Property(e => e.ProfileName).HasColumnName(actionOpt.ProfileName);
|
b.Property(e => e.ProfileName).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.ProfileName)));
|
||||||
b.Property(e => e.ProfileType).HasColumnName(actionOpt.ProfileType);
|
b.Property(e => e.ProfileType).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.ProfileType)));
|
||||||
b.Property(e => e.Sequence).HasColumnName(actionOpt.Sequence);
|
b.Property(e => e.Sequence).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.Sequence)));
|
||||||
b.Property(e => e.EndpointId).HasColumnName(actionOpt.EndpointId);
|
b.Property(e => e.EndpointId).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.EndpointId)));
|
||||||
b.Property(e => e.EndpointUri).HasColumnName(actionOpt.EndpointUri);
|
b.Property(e => e.EndpointUri).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.EndpointUri)));
|
||||||
b.Property(e => e.EndpointAuthId).HasColumnName(actionOpt.EndpointAuthId);
|
b.Property(e => e.EndpointAuthId).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.EndpointAuthId)));
|
||||||
b.Property(e => e.EndpointAuthType).HasColumnName(actionOpt.EndpointAuthType);
|
b.Property(e => e.EndpointAuthType).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.EndpointAuthType)));
|
||||||
b.Property(e => e.EndpointAuthTypeName).HasColumnName(actionOpt.EndpointAuthTypeName);
|
b.Property(e => e.EndpointAuthTypeName).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.EndpointAuthTypeName)));
|
||||||
b.Property(e => e.EndpointAuthApiKey).HasColumnName(actionOpt.EndpointAuthApiKey);
|
b.Property(e => e.EndpointAuthApiKey).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.EndpointAuthApiKey)));
|
||||||
b.Property(e => e.EndpointAuthApiValue).HasColumnName(actionOpt.EndpointAuthApiValue);
|
b.Property(e => e.EndpointAuthApiValue).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.EndpointAuthApiValue)));
|
||||||
b.Property(e => e.EndpointAuthApiKeyAddTo).HasColumnName(actionOpt.EndpointAuthApiKeyAddTo);
|
b.Property(e => e.EndpointAuthApiKeyAddTo).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.EndpointAuthApiKeyAddTo)));
|
||||||
b.Property(e => e.EndpointAuthApiKeyAddToName).HasColumnName(actionOpt.EndpointAuthApiKeyAddToName);
|
b.Property(e => e.EndpointAuthApiKeyAddToName).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.EndpointAuthApiKeyAddToName)));
|
||||||
b.Property(e => e.EndpointAuthToken).HasColumnName(actionOpt.EndpointAuthToken);
|
b.Property(e => e.EndpointAuthToken).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.EndpointAuthToken)));
|
||||||
b.Property(e => e.EndpointAuthUsername).HasColumnName(actionOpt.EndpointAuthUsername);
|
b.Property(e => e.EndpointAuthUsername).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.EndpointAuthUsername)));
|
||||||
b.Property(e => e.EndpointAuthPassword).HasColumnName(actionOpt.EndpointAuthPassword);
|
b.Property(e => e.EndpointAuthPassword).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.EndpointAuthPassword)));
|
||||||
b.Property(e => e.EndpointAuthDomain).HasColumnName(actionOpt.EndpointAuthDomain);
|
b.Property(e => e.EndpointAuthDomain).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.EndpointAuthDomain)));
|
||||||
b.Property(e => e.EndpointAuthWorkstation).HasColumnName(actionOpt.EndpointAuthWorkstation);
|
b.Property(e => e.EndpointAuthWorkstation).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.EndpointAuthWorkstation)));
|
||||||
b.Property(e => e.EndpointParamsId).HasColumnName(actionOpt.EndpointParamsId);
|
b.Property(e => e.EndpointParamsId).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.EndpointParamsId)));
|
||||||
b.Property(e => e.SqlConnectionId).HasColumnName(actionOpt.SqlConnectionId);
|
b.Property(e => e.SqlConnectionId).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.SqlConnectionId)));
|
||||||
b.Property(e => e.SqlConnectionServer).HasColumnName(actionOpt.SqlConnectionServer);
|
b.Property(e => e.SqlConnectionServer).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.SqlConnectionServer)));
|
||||||
b.Property(e => e.SqlConnectionDb).HasColumnName(actionOpt.SqlConnectionDb);
|
b.Property(e => e.SqlConnectionDb).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.SqlConnectionDb)));
|
||||||
b.Property(e => e.SqlConnectionUsername).HasColumnName(actionOpt.SqlConnectionUsername);
|
b.Property(e => e.SqlConnectionUsername).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.SqlConnectionUsername)));
|
||||||
b.Property(e => e.SqlConnectionPassword).HasColumnName(actionOpt.SqlConnectionPassword);
|
b.Property(e => e.SqlConnectionPassword).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.SqlConnectionPassword)));
|
||||||
b.Property(e => e.RestType).HasColumnName(actionOpt.RestType);
|
b.Property(e => e.RestType).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.RestType)));
|
||||||
b.Property(e => e.RestTypeName).HasColumnName(actionOpt.RestTypeName);
|
b.Property(e => e.RestTypeName).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.RestTypeName)));
|
||||||
b.Property(e => e.PreprocessingQuery).HasColumnName(actionOpt.PreprocessingQuery);
|
b.Property(e => e.PreprocessingQuery).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.PreprocessingQuery)));
|
||||||
b.Property(e => e.HeaderQuery).HasColumnName(actionOpt.HeaderQuery);
|
b.Property(e => e.HeaderQuery).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.HeaderQuery)));
|
||||||
b.Property(e => e.BodyQuery).HasColumnName(actionOpt.BodyQuery);
|
b.Property(e => e.BodyQuery).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.BodyQuery)));
|
||||||
b.Property(e => e.PostprocessingQuery).HasColumnName(actionOpt.PostprocessingQuery);
|
b.Property(e => e.PostprocessingQuery).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.PostprocessingQuery)));
|
||||||
b.Property(e => e.ErrorAction).HasColumnName(actionOpt.ErrorAction);
|
b.Property(e => e.ErrorAction).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.ErrorAction)));
|
||||||
b.Property(e => e.ErrorActionName).HasColumnName(actionOpt.ErrorActionName);
|
b.Property(e => e.ErrorActionName).HasColumnName(opt.GetColumn(entityName, nameof(RecActionView.ErrorActionName)));
|
||||||
|
|
||||||
b.HasMany(e => e.Results)
|
b.HasMany(e => e.Results)
|
||||||
.WithOne(r => r.Action)
|
.WithOne(r => r.Action)
|
||||||
.HasForeignKey(r => r.ActionId);
|
.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<ProfileView>(b =>
|
modelBuilder.Entity<ProfileView>(b =>
|
||||||
{
|
{
|
||||||
b.ToView(profileOpt.View.Name, profileOpt.View.Schema);
|
b.ToView(opt.Name, opt.Schema);
|
||||||
b.HasKey(e => e.Id);
|
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<ResultView>(b =>
|
modelBuilder.Entity<ResultView>(b =>
|
||||||
{
|
{
|
||||||
b.ToView(resultOpt.View.Name, resultOpt.View.Schema);
|
b.ToView(opt.Name, opt.Schema);
|
||||||
b.HasKey(e => e.Id);
|
b.HasKey(e => e.Id);
|
||||||
|
|
||||||
b.Property(e => e.Id).HasColumnName(resultOpt.Id);
|
b.Property(e => e.Id).HasColumnName(opt.GetColumn(entityName, nameof(ResultView.Id)));
|
||||||
b.Property(e => e.ActionId).HasColumnName(resultOpt.ActionId);
|
b.Property(e => e.ActionId).HasColumnName(opt.GetColumn(entityName, nameof(ResultView.ActionId)));
|
||||||
b.Property(e => e.ProfileId).HasColumnName(resultOpt.ProfileId);
|
b.Property(e => e.ProfileId).HasColumnName(opt.GetColumn(entityName, nameof(ResultView.ProfileId)));
|
||||||
b.Property(e => e.ProfileName).HasColumnName(resultOpt.ProfileName);
|
b.Property(e => e.ProfileName).HasColumnName(opt.GetColumn(entityName, nameof(ResultView.ProfileName)));
|
||||||
b.Property(e => e.StatusCode).HasColumnName(resultOpt.StatusCode);
|
b.Property(e => e.StatusCode).HasColumnName(opt.GetColumn(entityName, nameof(ResultView.StatusCode)));
|
||||||
b.Property(e => e.StatusName).HasColumnName(resultOpt.StatusName);
|
b.Property(e => e.StatusName).HasColumnName(opt.GetColumn(entityName, nameof(ResultView.StatusName)));
|
||||||
b.Property(e => e.Type).HasColumnName(resultOpt.Type);
|
b.Property(e => e.Type).HasColumnName(opt.GetColumn(entityName, nameof(ResultView.Type)));
|
||||||
b.Property(e => e.TypeName).HasColumnName(resultOpt.TypeName);
|
b.Property(e => e.TypeName).HasColumnName(opt.GetColumn(entityName, nameof(ResultView.TypeName)));
|
||||||
b.Property(e => e.Header).HasColumnName(resultOpt.Header);
|
b.Property(e => e.Header).HasColumnName(opt.GetColumn(entityName, nameof(ResultView.Header)));
|
||||||
b.Property(e => e.Body).HasColumnName(resultOpt.Body);
|
b.Property(e => e.Body).HasColumnName(opt.GetColumn(entityName, nameof(ResultView.Body)));
|
||||||
b.Property(e => e.Info).HasColumnName(resultOpt.Info);
|
b.Property(e => e.Info).HasColumnName(opt.GetColumn(entityName, nameof(ResultView.Info)));
|
||||||
b.Property(e => e.Error).HasColumnName(resultOpt.Error);
|
b.Property(e => e.Error).HasColumnName(opt.GetColumn(entityName, nameof(ResultView.Error)));
|
||||||
b.Property(e => e.AddedWho).HasColumnName(resultOpt.AddedWho);
|
b.Property(e => e.AddedWho).HasColumnName(opt.GetColumn(entityName, nameof(ResultView.AddedWho)));
|
||||||
b.Property(e => e.AddedWhen).HasColumnName(resultOpt.AddedWhen);
|
b.Property(e => e.AddedWhen).HasColumnName(opt.GetColumn(entityName, nameof(ResultView.AddedWhen)));
|
||||||
b.Property(e => e.ChangedWho).HasColumnName(resultOpt.ChangedWho);
|
b.Property(e => e.ChangedWho).HasColumnName(opt.GetColumn(entityName, nameof(ResultView.ChangedWho)));
|
||||||
b.Property(e => e.ChangedWhen).HasColumnName(resultOpt.ChangedWhen);
|
b.Property(e => e.ChangedWhen).HasColumnName(opt.GetColumn(entityName, nameof(ResultView.ChangedWhen)));
|
||||||
|
|
||||||
b.HasOne(r => r.Action)
|
b.HasOne(r => r.Action)
|
||||||
.WithMany(a => a.Results)
|
.WithMany(a => a.Results)
|
||||||
@@ -130,26 +153,41 @@ public class RecDbContext(DbContextOptions<RecDbContext> options, IOptions<DbMod
|
|||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey(r => r.ProfileId);
|
.HasForeignKey(r => r.ProfileId);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ConfigureHeaderQueryResult(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
const string entityName = nameof(HeaderQueryResult);
|
||||||
|
var opt = _dbModelOptions.GetEntity(entityName);
|
||||||
|
|
||||||
var headerOpt = _dbModelOptions.HeaderQueryResult;
|
|
||||||
modelBuilder.Entity<HeaderQueryResult>(b =>
|
modelBuilder.Entity<HeaderQueryResult>(b =>
|
||||||
{
|
{
|
||||||
b.HasNoKey();
|
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<BodyQueryResult>(b =>
|
modelBuilder.Entity<BodyQueryResult>(b =>
|
||||||
{
|
{
|
||||||
b.HasNoKey();
|
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<InsertObjectResult>(b =>
|
modelBuilder.Entity<InsertObjectResult>(b =>
|
||||||
{
|
{
|
||||||
b.HasNoKey();
|
b.HasNoKey();
|
||||||
b.Property(e => e.NewObjectId).HasColumnName(insertOpt.NewObjectId);
|
b.Property(e => e.NewObjectId).HasColumnName(opt.GetColumn(entityName, nameof(InsertObjectResult.NewObjectId)));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user