private void WriteOrderBy(ParserWriter writer, APSqlOrderByClause clause) { if (clause != null && clause.Next != null) { writer.WriteLine(); writer.WriteDirect("ORDER BY"); APSqlOrderPhrase phrase = clause.Next; bool isFirst = true; while (phrase != null) { if (!isFirst) { writer.Write(','); } else { isFirst = false; } WriteSelectExpression(writer, phrase.Expr); if (phrase.OrderAccording == APSqlOrderAccording.Desc) { writer.Write("DESC"); } phrase = phrase.Next as APSqlOrderPhrase; } } }
/// <summary> /// SQL 'ORDER BY' clause extensions. Add new 'ORDER BY' in clause. /// </summary> /// <param name="command">The command.</param> /// <param name="phrases">The 'ORDER BY' phrases.</param> /// <returns>The command.</returns> public static APSqlSelectCommand order_by_add(this APSqlSelectCommand command, IEnumerable <APSqlOrderPhrase> phrases) { if (command.OrderByClause == null || command.OrderByClause.Next == null) { command.OrderByClause = new APSqlOrderByClause(phrases); } else { APSqlOrderPhrase exist = command.OrderByClause.Last as APSqlOrderPhrase; exist.SetNext(phrases); } return(command); }
/// <summary> /// SQL 'ORDER BY' clause extensions. /// </summary> /// <param name="command">The command.</param> /// <param name="phrase">The 'ORDER BY' phrase.</param> /// <returns>The command.</returns> public static APSqlSelectCommand order_by(this APSqlSelectCommand command, APSqlOrderPhrase phrase) { command.OrderByClause = new APSqlOrderByClause(phrase); return(command); }
/// <summary> /// Create a 'ORDER BY' clause with one 'ORDER BY' phrase. /// </summary> /// <param name="phrase">'ORDER BY' phrase.</param> public APSqlOrderByClause(APSqlOrderPhrase phrase) { SetNext(phrase); }