Updated the namespaces for BodyQueryBehavior and HeaderQueryBehavior from ReC.Application.Common.Behaviors to ReC.Application.Common.Behaviors.Action. Adjusted related imports in DependencyInjection.cs to reflect this change for improved code organization.
Introduce InvokeActionTests.cs with comprehensive tests for:
- Placeholder replacement logic (ReplacePlaceholders) across int, bool, string, DateTime, DateTimeOffset types, multiple placeholders, and various prefix formats.
- Value extraction by column name (GetValueByColumnName), including models with and without [Column] attributes.
- Exception handling for unresolvable placeholders and invalid input scenarios.
These tests ensure robust coverage of both normal and error cases.
Introduce ReplacePlaceholders to PlaceholderExtensions, enabling replacement of {#...#COLUMN_NAME} placeholders in strings with property values from provided objects. Uses a generated regex for matching and converts values to SQL-compatible literals. Throws PlaceholderResolutionException if a column cannot be resolved. Refactored class to partial to support regex generation.
Introduced PlaceholderResolutionException in the ReC.Application.Common.Exceptions namespace. This exception provides detailed context when a placeholder cannot be resolved due to a missing property with a specific column name, including the placeholder, column name, and input string.
The <Folder Include="Common\Behaviors\Action\" /> entry was removed from ReC.Application.csproj, so the folder is no longer explicitly included in the project structure. No code or project references were affected.
Renamed the ReflectionExtensions class to PlaceholderExtensions and moved it from the ReC.Domain.Extensions namespace to ReC.Application.Common.Behaviors.InvokeAction to better reflect its purpose and location within the project structure.
Refactored GetValueByColumnName to use a generic type parameter constrained to class types. This enhances type safety and enables better type inference and static analysis when accessing property values by column name.
Introduced a static ReflectionExtensions class with a GetValueByColumnName extension method to retrieve property values by their [Column] attribute name. Also removed an unused folder reference from the project file.
Removed the DbModelConfigurationException class and all its usages from DbModelOptions and EntityOptions. Indexers in these classes no longer throw this exception when configuration is missing. Updated the project file to include the Common\Options\DbModel\ folder.
Removed all references to DbModel configuration from Program.cs and RecApplicationTestBase.cs. Deleted appsettings.DbModel.json, eliminating custom entity and column mapping definitions. The application no longer loads or uses DbModel configuration from JSON.
Eliminated all references to ConfigureDbModel in DependencyInjection.cs, including related imports, configuration methods, and required service tracking. Dependency injection configuration is otherwise unchanged.
Removed dependency on DbModelOptions and IOptions. Entity-to-view mappings are now hardcoded in OnModelCreating with fixed view names and schema. Property-to-column mappings now use EF Core conventions. Simplifies configuration and maintenance, but reduces flexibility for schema changes. Entity relationships remain explicitly configured.
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.
Added [Column] attributes to properties in BodyQueryResult, HeaderQueryResult, and InsertObjectResult to explicitly map them to their respective database columns. Also included necessary using directives for DataAnnotations.Schema to support these mappings. This enhances ORM compatibility and ensures correct property-to-column mapping.
Replaced GetEntity and GetColumn extension methods with indexers
on DbModelOptions and EntityOptions. Updated all usages to use
the new indexer syntax, improving code clarity and error handling
for missing entity or column configurations.
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.
Added options.ConfigureDbModel to the AddRecServices configuration, enabling Rec services to use settings from the "DbModel" section of the app configuration for enhanced database model customization.
Refactored RecDbContext to use DbModelOptions injected via IOptions, replacing hardcoded view and column names with configuration-driven mappings. This enables dynamic control of entity-to-database mapping through appsettings.json, improving flexibility and maintainability.
Introduce ConfigureDbModel methods to DependencyInjection for setting up DbModelOptions from code or configuration. Update required services tracking and add usage in Program.cs to enable structured DbModelOptions injection.
Replaced the old generic, dictionary-based entity configuration system with a new, strongly-typed options structure under ReC.Application.Common.Options.DbModel. Introduced specific options classes for each major database view and result type, each with clear property mappings and defaults. Added a ViewOptions class for view/schema info. Removed all legacy entity mapping infrastructure, resulting in a more maintainable and type-safe configuration approach.
Added a new "DbModel" section to appsettings.DbModel.json, defining property-to-column mappings for RecActionView, ProfileView, ResultView, HeaderQueryResult, BodyQueryResult, and InsertObjectResult. This centralizes and standardizes database view and query result configurations.
Renamed namespaces in PreprocessingBehavior and PostprocessingBehavior from .Action to .InvokeAction, and updated related using directives in DependencyInjection.cs. Added a folder entry for Common\Behaviors\Action\ in the project file for organization.
Added the Type property (ResultType) to every InsertResultCommand sent in PostprocessingBehavior, PreprocessingBehavior, and InvokeRecActionViewCommand. This ensures each result now includes its context (Post, Pre, or Main), both in normal and exception flows.
Updated InsertObjectProcedure to make related command properties nullable and removed default initializations. Updated handler to use null-conditional access for these properties. Changed InsertResultCommand.Type to required and updated tests accordingly. Improves null safety and clarifies required fields.
Refactored OutResDto to include additional properties such as Action, Profile, Status, and Type, and made several fields nullable. This enhances flexibility and allows for more comprehensive and optional data representation in API responses.
Extended InsertObjectProcedureHandler to include Result.Info, Result.Error, and Result.Type in both the SQL parameter list and the command string. This ensures these fields are correctly passed to and handled by the stored procedure.
Added a nullable Type property of ResultType to InsertResultCommand for enhanced result categorization. Also included the required using directive for ReC.Domain.Constants.
Added entity property mappings for RESULT_TYPE_ID (Type) and RESULT_TYPE (TypeName) columns in RecDbContext to support storing and retrieving result type information.
Imported ResultType and added Type (ResultType?) and TypeName (string?) properties to ResultView to support representing result types alongside status information.
Removed #pragma directives that suppressed CS0618 (obsolete API usage) warnings around app.UseMiddleware<ExceptionHandlingMiddleware>(). Obsolete warnings for this middleware will now be shown during compilation.
Removed [Obsolete] from ExceptionHandlingMiddleware, indicating it is no longer deprecated. Added using directive for ReC.Application.Common.Exceptions to support updated exception handling.
Added specific handling for RecActionException in the exception middleware. Now logs a warning with ActionId and ProfileId, returns a 422 Unprocessable Entity status, and provides detailed error information in the response.
Add ILogger support to InvokeRecActionViewsCommandHandler for enhanced error and warning logging. Log and continue on handled exceptions when appropriate, and rethrow for critical errors. Clean up and reorder using directives. This increases robustness and traceability during batch rec action processing.
Expose ActionId and ProfileId as public properties in the
RecActionException class, allowing external access to these
values from exception instances. Refactored the constructor
to use a block body.
Deleted the InvokeBatchRecActionViewsCommandExtensions class and its InvokeBatchRecActionView extension method for ISender. The command record and handler remain unchanged.
Replaced generic exception with RecActionException in PostprocessingBehavior when ErrorAction is Stop, providing ActionId and ProfileId for better error context. Added necessary using statements for the new exception and related namespaces.
Wrap exceptions in PreprocessingBehavior with RecActionException, including ActionId and ProfileId for better context and debugging. This enhances error reporting when ErrorAction is set to Stop.
Updated InvokeRecActionViewCommandHandler to throw a RecActionException with action Id and ProfileId when an error occurs and ErrorAction is set to Stop. This change enhances error traceability by providing more contextual information in exceptions.
Introduced RecActionException in ReC.Application.Common.Exceptions to encapsulate errors related to rec actions, including actionId, optional profileId, and inner exception details in the error message.
Refactored InvokeRecActionViewCommandHandler to enhance error handling by logging exceptions and conditionally rethrowing based on ErrorAction. Simplified NTLM HttpClient/handler management for proper disposal. Improved code structure and formatting for clarity.
Refactored PreprocessingBehavior and PostprocessingBehavior to send InsertResultCommand with only relevant info or error fields. Now throws exceptions when ErrorAction is Stop, allowing upstream error handling and preventing unnecessary or misleading result data. Improves consistency and clarity in error processing.
Refactored PreprocessingBehavior and PostprocessingBehavior for InvokeRecActionViewCommand to use MediatR's Unit as the response type instead of bool. Updated method signatures, return values, and DI registration accordingly to align with MediatR conventions for commands without return values.
Switch to exception-based error handling for invoking RecActionView actions, removing boolean return values and related checks. Update command and handler signatures to use void return type. Clean up unused using directives. This improves clarity and robustness of error management during batch processing.
Registered PostprocessingBehavior for InvokeRecActionViewCommand (with bool result) in the MediatR pipeline via DependencyInjection. This ensures both preprocessing and postprocessing behaviors are executed for this command.
Introduced PostprocessingBehavior as an IPipelineBehavior for InvokeRecActionViewCommand. This behavior handles post-processing by executing optional queries, serializing results, and logging outcomes via InsertResultCommand. It also manages error handling based on the action's ErrorAction setting, ensuring consistent result tracking after command execution.
Register PreprocessingBehavior in the MediatR pipeline specifically for InvokeRecActionViewCommand. Update using directives to reflect the shift from Procedures to Commands and from Common.Behaviors to Common.Behaviors.Action.
Refactored PreprocessingBehavior to serialize and log the results and errors of preprocessing SQL queries using InsertResultCommand. Now records both successful and failed executions, while preserving the stop-on-error behavior. Cleaned up and updated using directives.
The ExecuteDynamicSqlAsync method now returns an IEnumerable of
dictionaries representing query result rows, instead of a JSON
string. This allows consumers to work directly with the data
in its native .NET object form.