diff --git a/web/backend/Infrastructure/Infrastructure.Sql/DefaultSqlConnectionFactory.cs b/web/backend/Infrastructure/Infrastructure.Sql/DefaultSqlConnectionFactory.cs
index fff740e..5ef7cc9 100644
--- a/web/backend/Infrastructure/Infrastructure.Sql/DefaultSqlConnectionFactory.cs
+++ b/web/backend/Infrastructure/Infrastructure.Sql/DefaultSqlConnectionFactory.cs
@@ -9,12 +9,9 @@ namespace Infrastructure.Sql;
/// resolving the connection string from environment variables or application configuration.
///
/// The application configuration, used as a fallback source for the connection string.
-public class DefaultSqlConnectionFactory(IConfiguration configuration)
- : ISqlConnectionFactory
+public class DefaultSqlConnectionFactory(IConfiguration configuration) : ISqlConnectionFactory
{
- private readonly string _connectionString = GetConnectionString(
- configuration
- );
+ private readonly string _connectionString = GetConnectionString(configuration);
///
/// Creates a new, unopened using the resolved connection string.
@@ -39,10 +36,9 @@ public class DefaultSqlConnectionFactory(IConfiguration configuration)
private static string GetConnectionString(IConfiguration configuration)
{
// Check for full connection string first
- string? fullConnectionString = Environment.GetEnvironmentVariable(
- "DB_CONNECTION_STRING"
- );
- if (!string.IsNullOrEmpty(fullConnectionString)) return fullConnectionString;
+ string? fullConnectionString = Environment.GetEnvironmentVariable("DB_CONNECTION_STRING");
+ if (!string.IsNullOrEmpty(fullConnectionString))
+ return fullConnectionString;
// Try to build from individual environment variables (preferred method for Docker)
try
@@ -53,11 +49,12 @@ public class DefaultSqlConnectionFactory(IConfiguration configuration)
{
// Fall back to configuration-based connection string if env vars are not set
string? connString = configuration.GetConnectionString("Default");
- if (!string.IsNullOrEmpty(connString)) return connString;
+ if (!string.IsNullOrEmpty(connString))
+ return connString;
throw new InvalidOperationException(
"Database connection string not configured. Set DB_CONNECTION_STRING or DB_SERVER, DB_NAME, DB_USER, DB_PASSWORD env vars or ConnectionStrings:Default."
);
}
}
-}
\ No newline at end of file
+}
diff --git a/web/backend/Infrastructure/Infrastructure.Sql/ISqlConnectionFactory.cs b/web/backend/Infrastructure/Infrastructure.Sql/ISqlConnectionFactory.cs
index 78c26d6..8997656 100644
--- a/web/backend/Infrastructure/Infrastructure.Sql/ISqlConnectionFactory.cs
+++ b/web/backend/Infrastructure/Infrastructure.Sql/ISqlConnectionFactory.cs
@@ -12,4 +12,4 @@ public interface ISqlConnectionFactory
///
/// A new instance.
DbConnection CreateConnection();
-}
\ No newline at end of file
+}
diff --git a/web/backend/Infrastructure/Infrastructure.Sql/Infrastructure.Sql.csproj b/web/backend/Infrastructure/Infrastructure.Sql/Infrastructure.Sql.csproj
index b9ea4fa..7ff048e 100644
--- a/web/backend/Infrastructure/Infrastructure.Sql/Infrastructure.Sql.csproj
+++ b/web/backend/Infrastructure/Infrastructure.Sql/Infrastructure.Sql.csproj
@@ -6,15 +6,12 @@
Infrastructure.Sql
-
+
+
+
-
-
diff --git a/web/backend/Infrastructure/Infrastructure.Sql/Repository.cs b/web/backend/Infrastructure/Infrastructure.Sql/Repository.cs
index 6691682..b223cd1 100644
--- a/web/backend/Infrastructure/Infrastructure.Sql/Repository.cs
+++ b/web/backend/Infrastructure/Infrastructure.Sql/Repository.cs
@@ -29,4 +29,4 @@ public abstract class Repository(ISqlConnectionFactory connectionFactory)
/// The data reader positioned on the row to map.
/// The mapped entity instance.
protected abstract T MapToEntity(DbDataReader reader);
-}
\ No newline at end of file
+}
diff --git a/web/backend/Infrastructure/Infrastructure.Sql/SqlConnectionStringHelper.cs b/web/backend/Infrastructure/Infrastructure.Sql/SqlConnectionStringHelper.cs
index 4ccdc1f..a5ecb39 100644
--- a/web/backend/Infrastructure/Infrastructure.Sql/SqlConnectionStringHelper.cs
+++ b/web/backend/Infrastructure/Infrastructure.Sql/SqlConnectionStringHelper.cs
@@ -17,28 +17,20 @@ public static class SqlConnectionStringHelper
{
string server =
Environment.GetEnvironmentVariable("DB_SERVER")
- ?? throw new InvalidOperationException(
- "DB_SERVER environment variable is not set"
- );
+ ?? throw new InvalidOperationException("DB_SERVER environment variable is not set");
string dbName =
databaseName
?? Environment.GetEnvironmentVariable("DB_NAME")
- ?? throw new InvalidOperationException(
- "DB_NAME environment variable is not set"
- );
+ ?? throw new InvalidOperationException("DB_NAME environment variable is not set");
string user =
Environment.GetEnvironmentVariable("DB_USER")
- ?? throw new InvalidOperationException(
- "DB_USER environment variable is not set"
- );
+ ?? throw new InvalidOperationException("DB_USER environment variable is not set");
string password =
Environment.GetEnvironmentVariable("DB_PASSWORD")
- ?? throw new InvalidOperationException(
- "DB_PASSWORD environment variable is not set"
- );
+ ?? throw new InvalidOperationException("DB_PASSWORD environment variable is not set");
SqlConnectionStringBuilder builder = new()
{
@@ -47,7 +39,7 @@ public static class SqlConnectionStringHelper
UserID = user,
Password = password,
TrustServerCertificate = true,
- Encrypt = true
+ Encrypt = true,
};
return builder.ConnectionString;
@@ -61,4 +53,4 @@ public static class SqlConnectionStringHelper
{
return BuildConnectionString("master");
}
-}
\ No newline at end of file
+}