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
23 lines
560 B
C#
23 lines
560 B
C#
using System.Data;
|
|
|
|
using FabApprovalWorkerService.Models;
|
|
|
|
using Microsoft.Data.SqlClient;
|
|
|
|
namespace FabApprovalWorkerService.Services;
|
|
|
|
public interface IDbConnectionService {
|
|
IDbConnection GetConnection();
|
|
}
|
|
|
|
public class DbConnectionService : IDbConnectionService {
|
|
private readonly string _dbConnectionString;
|
|
|
|
public DbConnectionService(AppSettings appSettings) {
|
|
_dbConnectionString = appSettings.DbConnectionString;
|
|
}
|
|
|
|
public IDbConnection GetConnection() {
|
|
return new SqlConnection(_dbConnectionString);
|
|
}
|
|
} |