18 using System.Collections.Generic;
20 using System.Globalization;
44 this.fromSet = fromSet;
45 selectedColumns =
new List<SelectColumn>();
49 selectedColumns.Add(col);
64 SelectSingleColumn(column);
71 if (tableName.
Parent != null)
76 throw new InvalidOperationException(tableName +
".* is not a valid reference.");
78 AddAllFromTable(table);
82 for (
int p = 0; p < fromSet.SourceCount; ++p) {
84 AddAllFromTable(table);
89 ref
int aggregateCount) {
91 throw new InvalidOperationException(
"Sub-query expressions are invalid in select columns.");
97 exp = exp.
Prepare(fromSet.ExpressionPreparer);
100 var sqlRef = (SqlReferenceExpression) exp;
101 var colName = sqlRef.ReferenceName;
104 var alias = column.
Alias;
105 if (String.IsNullOrEmpty(alias)) {
106 resolvedName = colName;
112 InternalName = colName,
113 ResolvedName = resolvedName
116 var funcAlias = functionColumns.Count.
ToString(CultureInfo.InvariantCulture);
117 if (column.
Expression.HasAggregate(context)) {
122 var alias = column.
Alias;
123 if (
string.IsNullOrEmpty(alias))
124 alias = exp.ToString();
127 InternalName =
new ObjectName(FunctionTableName, funcAlias),
131 functionColumns.Add(newColumn);
138 int aggregateCount = 0;
139 var functionColumns =
new List<SelectColumn>();
140 var preparedColumns =
new List<SelectColumn>();
141 foreach (var column
in selectedColumns) {
142 var prepared = PrepareColumn(column, context, functionColumns, ref aggregateCount);
143 preparedColumns.Add(prepared);
QuerySelectColumns(QueryExpressionFrom fromSet)
void SelectAllColumnsFromAllSources()
ObjectName[] ColumnNames
Returns an array of ObjectName objects that references each column available in the table set item in...
override string ToString()
An expression that references an object within a context.
A single table resource item in a query which handles the behaviour of resolving references to column...
PreparedQuerySelectColumns Prepare(IRequest context)
Describes the name of an object within a database.
readonly QueryExpressionFrom fromSet
The tables we are selecting from.
void AddAllFromTable(IFromTableSource table)
virtual SqlExpression Prepare(IExpressionPreparer preparer)
Represents a column selected to be in the output of a select statement.
SqlExpression Expression
Gets the expression used to select the column.
SelectColumn PrepareColumn(SelectColumn column, IRequest context, IList< SelectColumn > functionColumns, ref int aggregateCount)
ObjectName Parent
Gets the parent reference of the current one, if any or null if none.
string Alias
Gets the name used to alias the select expression.
void SelectAllColumnsFromSource(ObjectName tableName)
string Name
Gets the name of the object being referenced.
static SqlReferenceExpression Reference(ObjectName objectName)
void SelectSingleColumn(SelectColumn col)
readonly List< SelectColumn > selectedColumns
Defines the base class for instances that represent SQL expression tree nodes.