EFIngresProvider/SqlGen/SqlGenerator/SqlGeneratorCommonVisitors.cs
/// <summary>
/// Helper method for AddColumns. Adds a column with the given column name 
/// to the Select list of the given select statement.
/// </summary>
/// <param name="selectStatement">The select statement to whose SELECT part the column should be added</param>
/// <param name="symbol">The symbol from which the column to be added originated</param>
/// <param name="columnList">Columns that have been added to the Select statement.
/// This is created in <see cref="AddDefaultColumns"/>.</param>
/// <param name="columnDictionary">A dictionary of the columns above.</param>
/// <param name="columnName">The name of the column to be added.</param>
Helper method for AddColumns. Adds a column with the given column name
to the Select list of the given select statement.
Helper method for AddColumns . Adds a column with the given column name to the Select list of the given select statement .
private void AddColumn(SqlSelectStatement selectStatement, Symbol symbol, List<Symbol> columnList, Dictionary<string, Symbol> columnDictionary, string columnName)
        {
            allColumnNames[columnName] = 0;
            Symbol columnSymbol;
            if (!symbol.Columns.TryGetValue(columnName, out columnSymbol))
            {
                columnSymbol = new Symbol(columnName, null);
                symbol.Columns.Add(columnName, columnSymbol);
            }
            if (symbol.OutputColumnsRenamed)
            {
                selectStatement.Select.Append(new SelectColumn(columnSymbol, symbol, columnSymbol));
                selectStatement.OutputColumns.Add(columnSymbol.Name, columnSymbol);
            }
            else
            {
                selectStatement.Select.Append(new SelectColumn(columnSymbol, symbol, new Symbol(columnName)));
            }
            if (columnDictionary.ContainsKey(columnName))
            {
                columnDictionary[columnName].NeedsRenaming = true;
                columnSymbol.NeedsRenaming = true;
            }
            else
            {
                columnDictionary[columnName] = symbol.Columns[columnName];
            }
            columnList.Add(columnSymbol);
        }
private void AddColumn ( SqlSelectStatement selectStatement , Symbol symbol , List < Symbol > columnList , Dictionary < string , Symbol > columnDictionary , string columnName ) { allColumnNames [ columnName ] = 0 ; Symbol columnSymbol ; if ( ! symbol . Columns . TryGetValue ( columnName , out columnSymbol ) ) { columnSymbol = new Symbol ( columnName , null ) ; symbol . Columns . Add ( columnName , columnSymbol ) ; } if ( symbol . OutputColumnsRenamed ) { selectStatement . Select . Append ( new SelectColumn ( columnSymbol , symbol , columnSymbol ) ) ; selectStatement . OutputColumns . Add ( columnSymbol . Name , columnSymbol ) ; } else { selectStatement . Select . Append ( new SelectColumn ( columnSymbol , symbol , new Symbol ( columnName ) ) ) ; } if ( columnDictionary . ContainsKey ( columnName ) ) { columnDictionary [ columnName ] . NeedsRenaming = true ; columnSymbol . NeedsRenaming = true ; } else { columnDictionary [ columnName ] = symbol . Columns [ columnName ] ; } columnList . Add ( columnSymbol ) ; }
Helper method for AddColumns.
Helper method for AddColumns .
// Since all renaming happens in the second phase // we lose nothing by setting the next column name index to 0 // many times. // Create a new symbol/reuse existing symbol for the column // we do not care about the types of columns, so we pass null // when construction the symbol. // We use the actual name before the "AS", the new name goes // after the AS. // Check for column name collisions.
selectStatement
SqlSelectStatement
The select statement to whose SELECT part the column should be added
The select statement to whose SELECT part the column should be added
symbol
Symbol
The symbol from which the column to be added originated
The symbol from which the column to be added originated
columnList
List<Symbol>
Columns that have been added to the Select statement.
This is created in .
Columns that have been added to the Select statement . This is created in .
columnDictionary
Dictionary<string, Symbol>
A dictionary of the columns above.
A dictionary of the columns above .
columnName
string
The name of the column to be added.
The name of the column to be added .