Align .editorconfig files
When debugging only app.Services.GetRequiredService<IPCRBService>(); Injected AppSettings instead of using GetEnvironmentVariable at Services level Get ready to use VSCode IDE
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
using System.Data;
|
||||
|
||||
using MesaFabApproval.Models;
|
||||
|
||||
using Microsoft.Data.SqlClient;
|
||||
|
||||
namespace MesaFabApproval.API.Services;
|
||||
@ -11,12 +13,10 @@ public interface IDbConnectionService {
|
||||
public class DbConnectionService : IDbConnectionService {
|
||||
private readonly string _dbConnectionString;
|
||||
|
||||
public DbConnectionService() {
|
||||
_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);
|
||||
}
|
||||
}
|
||||
public IDbConnection GetConnection() =>
|
||||
new SqlConnection(_dbConnectionString);
|
||||
}
|
Reference in New Issue
Block a user