Update database handling code (#247)

This commit is contained in:
2026-08-25 13:42:51 -04:00
committed by GitHub
parent 03ca966708
commit 8a047e8d9f
37 changed files with 386 additions and 405 deletions

View File

@@ -0,0 +1,21 @@
using System.Data.Common;
namespace Database.Connection;
/// <summary>
/// Base class for Dapper-based repositories, providing shared connection creation for derived
/// repository implementations.
/// </summary>
public abstract class DapperRepository(ISqlConnectionFactory connectionFactory)
{
/// <summary>
/// Creates and opens a new database connection using the configured <see cref="ISqlConnectionFactory" />.
/// </summary>
/// <exception cref="DbException">Thrown when the connection cannot be opened.</exception>
protected async Task<DbConnection> CreateConnection()
{
DbConnection connection = connectionFactory.CreateConnection();
await connection.OpenAsync();
return connection;
}
}