public void Insert(WordHashtagPair pair) { string sql = $"INSERT INTO {_streamNameWordHashtagPairs} (word, hashtag) VALUES (@word, @hashtag);"; using (NpgsqlCommand command = new NpgsqlCommand(sql, _connection)) { var transaction = _connection.BeginTransaction(); command.Transaction = transaction; command.Parameters.Add("@word", NpgsqlTypes.NpgsqlDbType.Varchar).Value = pair.Word; command.Parameters.Add("@hashtag", NpgsqlTypes.NpgsqlDbType.Varchar).Value = pair.HashTag; command.ExecuteNonQuery(); try { transaction.Commit(); } catch (Exception) { transaction.Rollback(); } } }
public void Insert(WordHashtagPair pair) { _pipelineRepo.Insert(pair); _postgreRepo.Insert(pair); }