protected virtual async Task <T> ExecuteAsync <T>( [NotNull] IRelationalConnection connection, [NotNull] RelationalCommand command, [NotNull] Func <DbCommand, Task <T> > action, CancellationToken cancellationToken = default(CancellationToken)) { await connection.OpenAsync(cancellationToken); try { using (var dbCommand = command.CreateCommand(connection)) { Logger.LogCommand(dbCommand); return(await action(dbCommand)); } } finally { connection.Close(); } }
protected virtual T Execute <T>( [NotNull] IRelationalConnection connection, [NotNull] RelationalCommand command, [NotNull] Func <DbCommand, T> action) { // TODO Deal with suppressing transactions etc. connection.Open(); try { using (var dbCommand = command.CreateCommand(connection)) { Logger.LogCommand(dbCommand); return(action(dbCommand)); } } finally { connection.Close(); } }