override public void Finish() { foreach (object obj in SyntaxList) { if (obj is SelectField) { SelectField selectField = obj as SelectField; if (selectField.BetweenRecord) { this.Begin = selectField.Begin; this.End = selectField.End; } SelectFields.Add(selectField); } else if (obj is SelectFrom) { SelectFroms.Add(obj as SelectFrom); } else if (obj is OrderBy) { OrderBys.Add(obj as OrderBy); } else if (obj is Where) { Where = obj as Where; } } }
public QueryExpression OrderBy(params IOrderExpression[] orderExpressions) { foreach (IOrderExpression orderExpression in orderExpressions) { OrderBys.Add(orderExpression); } return(this); }
protected override string FormatPagingSql(DbTextWriter writer, Constraint constraint) { Argument.Assert.IsNotNull(writer, nameof(writer)); OnWriteSelect(writer); OnWriteFrom(writer); OnWriteWhere(writer); OnWriteGroupBys(writer); OnWriteHaving(writer); string subQuery = writer.ToString(); string outerSelectList; string orderbylist; if (OrderBys.Count == 0 && SelectTable != null) { if (SelectTable.HasIdentityColumn) { OrderBys.Add(new OrderBy(SelectTable.IdentityColumn, OrderByDirection.Asc)); } else if (SelectTable.HasPrimaryKey) { foreach (QueryColumn key in SelectTable.PrimaryKey) { OrderBys.Add(new OrderBy(key, OrderByDirection.Asc)); } } else { throw new InvalidOperationException("The paging command has no OrderBy column specified and the table has no identity column or primary key defined."); } } using (DbTextWriter outerSelectWriter = new DbTextWriter()) { outerSelectWriter.WriteSelectColumns(Columns); outerSelectList = outerSelectWriter.ToString(); } using (DbTextWriter orderByWriter = new DbTextWriter()) { orderByWriter.WriteOrderBy(OrderBys, constraint); orderbylist = orderByWriter.ToString(); } Parameters.Add("_pi", constraint.Start); Parameters.Add("_ps", constraint.Count); return(string.Format(PagingSelectTemplate, outerSelectList, orderbylist, subQuery)); }
public void AppendOrderBy(OrderBy orderBy) { OrderBys.Add(orderBy); }
public void AppendOrderBy(IQueryableColumn column, OrderByDirection direction) { OrderBys.Add(new OrderBy(column, direction)); }