private void zReadTableResult(DataReaderHelper reader)
        {
            TableResultMapping tableResultMapping = (TableResultMapping)m_Step.ResultMapping;

            ListStateVariable listStateVariable = null;

            if (tableResultMapping.ObjectSetListName != null && tableResultMapping.ObjectSetClassName != null)
            {
                //TODO: there is similar logic in GroupStepExecutor.zCreateElementSetIterator - refactor into common method on DataScope.
                listStateVariable = (ListStateVariable)CurrentScope.DataScope.GetStateVariable(tableResultMapping.ObjectSetListName);
                if (listStateVariable == null)
                {
                    listStateVariable = new ListStateVariable(DataUtils.GetUnscopedVariableName(tableResultMapping.ObjectSetListName), tableResultMapping.PersistenceMode, new List <IStateVariable>());
                    CurrentScope.DataScope.SetStateVariable(tableResultMapping.ObjectSetListName, listStateVariable);
                }
                listStateVariable.IncludeInXML = tableResultMapping.IncludeInXML;
            }

            int resultCount = 1;

            while (reader.Read())
            {
                ObjectStateVariable objectStateVariable = null;
                if (listStateVariable != null)
                {
                    string listItemName = String.Format("{0}{1}", tableResultMapping.ObjectSetClassName, resultCount);
                    objectStateVariable = new ObjectStateVariable(listItemName, tableResultMapping.ObjectSetClassName, tableResultMapping.PersistenceMode, new Dictionary <string, IStateVariable>());
                    listStateVariable.Value.Add(objectStateVariable);
                }

                foreach (TableResultMap tableMap in tableResultMapping.TableMapping)
                {
                    //TODO: for now all data is being converted to string. Once we are doing something with the variable type system,
                    //      type the variables appropriately when reading them in.
                    object         value         = reader.GetNullableValue(tableMap.ColumnName);
                    IStateVariable stateVariable = new StateVariable <string>(DataUtils.GetUnscopedVariableName(tableMap.StateVariable),
                                                                              DataType.String,
                                                                              tableMap.XMLFieldOutputMode,
                                                                              tableMap.PersistenceMode,
                                                                              Convert.ToString(value));
                    if (objectStateVariable != null && stateVariable.Name == tableMap.StateVariable)
                    {
                        //stateVariable.Name == tableMap.StateVariable checks that tableMap.StateVariable has no explicit scope.
                        //If it has an explicit scope, stateVariable has to be set through CurrentScope.DataScope in the else block.
                        objectStateVariable.Value.Add(tableMap.StateVariable, stateVariable);
                    }
                    else
                    {
                        CurrentScope.DataScope.SetStateVariable(tableMap.StateVariable, stateVariable);
                    }
                }

                resultCount++;
            }
        }