示例#1
0
        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;
                }
            }
        }
示例#2
0
        /// <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);
        }
示例#3
0
 /// <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);
 }
示例#4
0
 /// <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);
 }
示例#5
0
		/// <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);
		}