private async Task InsertInTransactionAsync(DbCommand sqlCommand, IEnumerable<JournalEntry> journalEntries)
{
using (var tx = sqlCommand.Connection.BeginTransaction())
{
sqlCommand.Transaction = tx;
try
{
foreach (var entry in journalEntries)
{
CopyParamsToCommand(sqlCommand, entry);
var result = await sqlCommand.ExecuteNonQueryAsync();
if (result != 1)
{
Log.Error("Persisted event operation was expected to return 1, but returned [{0}]", result);
}
}
tx.Commit();
}
catch (Exception)
{
tx.Rollback();
throw;
}
}
}
}