Apply options pattern for database connection strings to Chapter 3#213
Closed
Apply options pattern for database connection strings to Chapter 3#213
Conversation
Co-authored-by: kamilbaczek <74410956+kamilbaczek@users.noreply.github.com>
Co-authored-by: kamilbaczek <74410956+kamilbaczek@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Apply Options Pattern for Database Connection Strings in Chapter 3
Apply options pattern for database connection strings to Chapter 3
Sep 3, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR applies the options pattern for database connection strings to Chapter 3, following the same approach implemented in PR #212 for Chapter 2. The changes improve type safety and follow .NET configuration best practices by replacing direct configuration string access with strongly-typed options classes.
Changes Made
1. Created DatabaseOptions Classes
Added
DatabaseOptionsclasses for each service module:Fitnet.Contracts.Infrastructure/Database/DatabaseOptions.csFitnet.Passes.DataAccess/Database/DatabaseOptions.csFitnet.Offers.DataAccess/Database/DatabaseOptions.csFitnet.Reports/DataAccess/DatabaseOptions.cs2. Updated Database Modules
Replaced direct
GetConnectionString()calls with the options pattern:Before:
After:
3. Updated DatabaseConnectionFactory
Modified the Reports module's
DatabaseConnectionFactoryto useIOptions<DatabaseOptions>instead of directly accessing configuration.4. Updated Configuration Structure
Changed configuration files from the flat structure:
To the structured options pattern:
5. Updated Integration Test Configurations
Updated all
*DatabaseConfiguration.csfiles in integration tests to use the new configuration structure.Benefits
Testing
All integration test configurations have been updated to work with the new options pattern. The changes maintain backward compatibility for the database functionality while improving the configuration management approach.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.