using System.Data.Common; namespace Infrastructure.Sql; /// /// Base class for Dapper-based repositories, providing shared connection creation for derived /// repository implementations. /// public abstract class Repository(ISqlConnectionFactory connectionFactory) where T : class { /// /// Creates and opens a new database connection using the configured . /// /// Thrown when the connection cannot be opened. protected async Task CreateConnection() { DbConnection connection = connectionFactory.CreateConnection(); await connection.OpenAsync(); return connection; } }