22 lines
497 B
C#
22 lines
497 B
C#
using System.Data.Common;
|
|
using CPATapi.Server.Interfaces;
|
|
using Microsoft.Data.SqlClient;
|
|
|
|
namespace CPATapi.Server.Repository;
|
|
|
|
public class Repository: IRepository
|
|
{
|
|
private readonly IConfiguration _config;
|
|
|
|
protected Repository(IConfiguration config)
|
|
{
|
|
_config = config;
|
|
}
|
|
protected async Task<DbConnection> OpenAsync(string name)
|
|
{
|
|
var db = new SqlConnection(_config.GetConnectionString(name));
|
|
await db.OpenAsync();
|
|
return db;
|
|
}
|
|
}
|