Exemple #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;
                }
            }
        }
Exemple #2
0
 /// <summary>
 /// SQL 'ORDER BY' clause extensions.
 /// </summary>
 /// <param name="command">The command.</param>
 /// <param name="clause">The 'ORDER BY' clause.</param>
 /// <returns>The command.</returns>
 public static APSqlSelectCommand order_by(this APSqlSelectCommand command, APSqlOrderByClause clause)
 {
     command.OrderByClause = clause;
     return(command);
 }
		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;
				}
			}
		}