Fetching a number of data tables from a stored procedure Within a method, this code is calling a SPROC that is doing a 'select *' from 9 different views. This method then goes on to access the returned DataTableCollection array by the index specified here (0-9). If the order of the stored procedure select statements ever changed, this would also need changing round here.

This seriously looks dodgy to me. Does anyone have any opinions?

if (_dataSet != null)
            {
                _applicationContext = new ApplicationContext();

                //build the object for System Mode.
                _applicationContext.SystemMode = BuildSystemMode(CheckDataTableScope(_dataSet.Tables,0));

                //build the object for data parameters.
                _dataParameters = BuildDataParameters(CheckDataTableScope(_dataSet.Tables, 1));

                //build the object for data columns.
                _dataColumns = BuildDataColumns(CheckDataTableScope(_dataSet.Tables, 2));

                //build the object for data command.
                _applicationContext.DataCommand = _dataCommand = BuildDataCommand(CheckDataTableScope(_dataSet.Tables, 3));

                //build the object for screens.
                _screenConfig = BuildScreen(CheckDataTableScope(_dataSet.Tables, 4));

                //build the object for user menus.
                _applicationContext.UserMenus = BuildUserMenu(CheckDataTableScope(_dataSet.Tables, 5));

                //build the object for application menus.
                _applicationContext.ApplicationMenus = BuildApplicationMenus(CheckDataTableScope(_dataSet.Tables, 6));

                //build the object for system messages.
                _applicationContext.SystemMessages = BuildSystemMessages(CheckDataTableScope(_dataSet.Tables, 7));

                //build the object for widget configuration.
                _applicationContext.WidgetConfigs = BuildWidgetConfig(CheckDataTableScope(_dataSet.Tables, 8));
            }
Couple of things.  

I would encapsulate the "magic" numbers into an enum

public enum DataSetTableInfo
{
    System = 0,
    Parameters = 1,
    DataColumns = 2
    //etc 
}


then change the method Sig of CheckDataTableScope to take the enum instead of an int.

If CheckDataTableScope method isn't public or someplace else you are using it without _dataSet I would drop passing _dataSet into it.  Just makes method sig more chatty than needs to be. If you can pass others values in for _dataSet then I would still probably lean towards two methods or have a default value for parameter.  Something like

private DataTable CheckDataTableScope(DataSetTableInfo dataSetTableInfo)
{
    return CheckDataTableScope(_dataSet, dataSetTableInfo);
}

public DataTable CheckDataTableScope(DataSet ds, DataSetTableInfo dataSetTableInfo)
{
}


Then your calls to the fill in the data change to be like

 if (_dataSet != null)
 {
     _applicationContext = new ApplicationContext();

     //build the object for System Mode.
     _applicationContext.SystemMode = BuildSystemMode(CheckDataTableScope(DataSetTableInfo.System));

     //build the object for data parameters.
     _dataParameters = BuildDataParameters(CheckDataTableScope(DataSetTableInfo.Parameters));

     //build the object for data columns.
     _dataColumns = BuildDataColumns(CheckDataTableScope(DataSetTableInfo.DataColumns));


To me this seems more readable, not in love with the method name of CheckDataTableScope but I don't know what that method actually does.  Plus if the stored procedure changes you can just update the enum to add more tables or change it to match the new table order and not touch any other piece of code.  

You can cast the enum to the int of the DataTable in CheckDataTableScope 

var tableIndex = (int) dataSetTableInfo;

if (tableIndex &lt;= ds.Tables.Count)
{
   var dt = ds.Tables[tableIndex];
}