mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 20:13:49 +00:00
Restructure project
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
using Microsoft.Data.SqlClient;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
|
||||
namespace DataAccessLayer.Sql
|
||||
{
|
||||
public class DefaultSqlConnectionFactory(IConfiguration configuration) : ISqlConnectionFactory
|
||||
{
|
||||
private readonly string _connectionString = Environment.GetEnvironmentVariable("DB_CONNECTION_STRING")
|
||||
?? configuration.GetConnectionString("Default")
|
||||
?? throw new InvalidOperationException(
|
||||
"Database connection string not configured. Set DB_CONNECTION_STRING env var or ConnectionStrings:Default."
|
||||
);
|
||||
|
||||
public SqlConnection CreateConnection()
|
||||
{
|
||||
return new SqlConnection(_connectionString);
|
||||
}
|
||||
}
|
||||
}
|
||||
9
Repository/Repository.Core/Sql/ISqlConnectionFactory.cs
Normal file
9
Repository/Repository.Core/Sql/ISqlConnectionFactory.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using Microsoft.Data.SqlClient;
|
||||
|
||||
namespace DataAccessLayer.Sql
|
||||
{
|
||||
public interface ISqlConnectionFactory
|
||||
{
|
||||
SqlConnection CreateConnection();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user