Architecture Advisory

AI, integration, and cloud architecture advisory

Edit DBQueryStep to enable multiple rows return

Editorial architecture visual showing system boundaries, service interaction, and technical tradeoffs

By default, the DBQueryStep only looks for first row, in which case it will cause problem in multiple rows result.

I slightly changed the code in BizUnit to make this viable. As a result, stuff all columns to be returned in the <rows> secion, i.e.

     <Rows>
        <Columns>
          <TotalRecordCount>1</TotalRecordCount>
          <Direction>IN</Direction>
          <TotalRecordCount>1</TotalRecordCount>
          <Direction>OUT</Direction>
        </Columns>
      </Rows>

Updated code in DBQueryStep.cs,

                foreach (DBRowToValidate row in this.DBRowsToValidate.RowsToValidate)
                {
                    DataRow bamDBRow;
                    int columnsCount = 0;

                    // Get the element which has the unique flag on…
                    //DBCellToValidate uniqueCell = row.UniqueCell;
                    //if (null != uniqueCell)
                    //{
                    //    DataRow[] bamDBRowArray =
                    //        ds.Tables[0].Select(
                    //            string.Format(“{0} = ‘{1}’”, uniqueCell.ColumnName, uniqueCell.ExpectedValue));
                    //    bamDBRow = bamDBRowArray[0];
                    //}
                    //else
                    //{
                    //    bamDBRow = ds.Tables[0].Rows[0];
                    //    columnsCount = ds.Tables[0].Columns.Count;
                    //}

                    bamDBRow = ds.Tables[0].Rows[0];
                    columnsCount = ds.Tables[0].Columns.Count;

                    IList<DBCellToValidate> cells = row.Cells;
                    int counter=0;
                    int rowCounter = 0;
                    foreach (DBCellToValidate cell in cells)
                    {
                        if ((counter>0)&&(counter%columnsCount==0))
                        {
                            rowCounter++;
                        }

                        counter++;

                        bamDBRow = ds.Tables[0].Rows[rowCounter];

                        object dbData = bamDBRow[cell.ColumnName];
                       
                        string dbDataStringValue = “”;
                        if (0 == ValidateData(dbData, cell.ExpectedValue, ref dbDataStringValue))
                        {
                            context.LogInfo(“Validation succeeded for field: {0} equals: {1}”, cell.ColumnName,
                                            dbDataStringValue);
                        }
                        else
                        {
                            throw new Exception(
                                String.Format(
                                    “Validation failed for field: {0}. Expected value: {1}, actual value: {2}”,
                                    cell.ColumnName, cell.ExpectedValue, dbDataStringValue));
                        }
                    }

Working through an AI architecture, integration boundary, or modernization decision right now?