public static FromTerm SubQuery(string query, string alias) { FromTerm term = new FromTerm(); term.expr = query; term.alias = alias; term.type = FromTermType.SubQuery; return term; }
public static FromTerm Table(string tableName, string alias, string ns1, string ns2) { FromTerm term = new FromTerm(); term.expr = tableName; term.alias = alias; term.type = FromTermType.Table; term.ns1 = ns1; term.ns2 = ns2; return term; }
public SelectColumn(string columnName, FromTerm table, string columnAlias, SqlAggregationFunction function) { if (function == SqlAggregationFunction.None) { this.expr = SqlExpression.Field(columnName, table); } else { this.expr = SqlExpression.Function(function, SqlExpression.Field(columnName, table)); } this.alias = columnAlias; }
public static SqlExpression Field(string fieldName, FromTerm table) { SqlExpression expression = new SqlExpression(); expression.val = fieldName; expression.table = table; expression.type = SqlExpressionType.Field; return expression; }
public OrderByTerm(string field, FromTerm table, OrderByDirection dir) { this.field = field; this.table = table; this.direction = dir; }
public SelectColumn(string columnName, FromTerm table, string columnAlias) : this(columnName, table, columnAlias, SqlAggregationFunction.None) { }
public SelectColumn(string columnName, FromTerm table) : this(columnName, table, null) { }
private void ApplyOrderBy(OrderByTermCollection terms, SelectQuery orderQuery, bool forward, FromTerm table) { foreach (SkyMap.Net.SqlOM.OrderByTerm term in terms) { OrderByDirection dir = term.Direction; if (!(forward || (dir != OrderByDirection.Ascending))) { dir = OrderByDirection.Descending; } else if (!(forward || (dir != OrderByDirection.Descending))) { dir = OrderByDirection.Ascending; } orderQuery.OrderByTerms.Add(new SkyMap.Net.SqlOM.OrderByTerm(this.FormatSortFieldName(term.Field.ToString()), table, dir)); } }
protected virtual void RenderFromTerm(StringBuilder builder, FromTerm table, string tableSpace) { if (table.Type == FromTermType.Table) { if (table.Ns1 != null) { this.TableNamespace(builder, table.Ns1); } if (table.Ns2 != null) { this.TableNamespace(builder, table.Ns2); } if (((table.Ns1 == null) && (table.Ns2 == null)) && (tableSpace != null)) { this.TableNamespace(builder, tableSpace); } this.Identifier(builder, (string) table.Expression); } else if (table.Type == FromTermType.SubQuery) { builder.AppendFormat("( {0} )", table.Expression); } else { if (table.Type != FromTermType.SubQueryObj) { throw new InvalidQueryException("Unknown FromExpressionType: " + table.Type.ToString()); } builder.AppendFormat("( {0} )", this.RenderSelect((SelectQuery) table.Expression)); } if (table.Alias != null) { builder.AppendFormat(" ", new object[0]); this.Identifier(builder, table.Alias); } }
public GroupByTerm(string field, FromTerm table) { this.field = field; this.table = table; }