Ejemplo n.º 1
0
        public async Task <string> InvokeIbmDb2QueryAsync(string tableName)
        {
            var teamMembers = new List <string>();

            using (var connection = new DB2Connection(Db2Configuration.Db2ConnectionString))
            {
                connection.Open();

                using (var command = new DB2Command("SELECT LASTNAME FROM EMPLOYEE FETCH FIRST ROW ONLY", connection))
                {
                    using (var reader = await command.ExecuteReaderAsync())
                    {
                        while (await reader.ReadAsync())
                        {
                            teamMembers.Add(reader.GetString(reader.GetOrdinal("LASTNAME")));
                        }
                    }
                }

                var insertSql = string.Format(InsertHotelDB2Sql, tableName);
                var countSql  = string.Format(CountHotelDB2Sql, tableName);
                var deleteSql = string.Format(DeleteHotelDB2Sql, tableName);

                using (var command = new DB2Command(insertSql, connection))
                {
                    var insertCount = command.ExecuteNonQueryAsync();
                }

                using (var command = new DB2Command(countSql, connection))
                {
                    var hotelCount = command.ExecuteScalarAsync();
                }

                using (var command = new DB2Command(deleteSql, connection))
                {
                    var deleteCount = command.ExecuteNonQueryAsync();
                }
            }

            return(string.Join(",", teamMembers));
        }