Pull Request 33523 suggestions
Pull Request 33520 suggestions Injected AppSettings instead of using GetEnvironmentVariable at Services level When debugging only app.Services.GetRequiredService<IPCRBService>(); Get ready to use VSCode IDE Align .editorconfig files
This commit is contained in:
@ -1,7 +1,8 @@
|
||||
using Microsoft.Data.SqlClient;
|
||||
using Microsoft.Data.Sqlite;
|
||||
using System.Data;
|
||||
|
||||
using System.Data;
|
||||
using FabApprovalWorkerService.Models;
|
||||
|
||||
using Microsoft.Data.SqlClient;
|
||||
|
||||
namespace FabApprovalWorkerService.Services;
|
||||
|
||||
@ -10,17 +11,13 @@ public interface IDbConnectionService {
|
||||
}
|
||||
|
||||
public class DbConnectionService : IDbConnectionService {
|
||||
private readonly string _envName;
|
||||
private readonly string _dbConnectionString;
|
||||
|
||||
public DbConnectionService() {
|
||||
_envName = Environment.GetEnvironmentVariable("FabApprovalEnvironmentName") ??
|
||||
throw new ArgumentNullException("FabApprovalEnvironmentName environment variable not found");
|
||||
_dbConnectionString = Environment.GetEnvironmentVariable("FabApprovalDbConnectionString") ??
|
||||
throw new ArgumentNullException("FabApprovalDbConnectionString environment variable not found");
|
||||
public DbConnectionService(AppSettings appSettings) {
|
||||
_dbConnectionString = appSettings.DbConnectionString;
|
||||
}
|
||||
|
||||
public IDbConnection GetConnection() {
|
||||
return new SqlConnection(_dbConnectionString);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user