One way to reduce repetitive code is through the usage of the [template method pattern][1]. In your template method: 1. Establish a connection 2. Execute database operation (this is the customizable step) 3. Close the connection ``` private async Task<T> GetAsync<T>(Func<IDbConnection, Task<T>> databaseOperation) { using IDbConnection myConnection = new SnowflakeDbConnection(connectionString: _connectionString); myConnection.Open(); var result = await databaseOperation(myConnection).ConfigureAwait(false); return result; } ``` Then you can rewrite your publicly exposed methods: ``` public async Task<IEnumerable<T>> GetAllAsync<T>(string selectSqlCommand) => await GetAsync(conn => conn.QueryAsync<T>(selectSqlCommand)); public async Task<T> GetSingleOrDefaultById<T>(string sqlCommand, int id) => await GetAsync(conn => conn.QuerySingleOrDefaultAsync<T>(sqlCommand, new { id })); ``` [1]: https://refactoring.guru/design-patterns/template-method/csharp/example