Files
the-biergarten-app/web/backend/Infrastructure/Infrastructure.Sql/Repository.cs
Aaron Po cac6d7f193 Replace stored-procedure repositories with Dapper-based repositories
Removes the USP_* stored procedures for Auth, Location, and Brewery
data access in favour of services built with Dapper.

Adds a new Features.Locations slice and optimistic concurrency support
for the Brewery slice.
2026-08-18 06:50:34 -04:00

23 lines
777 B
C#

using System.Data.Common;
namespace Infrastructure.Sql;
/// <summary>
/// Base class for Dapper-based repositories, providing shared connection creation for derived
/// repository implementations.
/// </summary>
public abstract class Repository<T>(ISqlConnectionFactory connectionFactory)
where T : class
{
/// <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;
}
}