Example #1
0
        void ApplyOrderBy(OrderByTermCollection terms, SelectQuery orderQuery, bool forward, FromTerm table)
        {
            foreach (OrderByTerm expr in terms)
            {
                OrderByDir dir = expr.Direction;

                //Reverse order direction if required
                if (!forward && dir == OrderByDir.Asc)
                {
                    dir = OrderByDir.Desc;
                }
                else if (!forward && dir == OrderByDir.Desc)
                {
                    dir = OrderByDir.Asc;
                }

                orderQuery.OrderByTerms.Add(new OrderByTerm(FormatSortFieldName(expr.Field.ToString()), table, dir));
            }
        }
Example #2
0
 /// <summary>Аналог конструкции SELECT ... ORDER BY</summary>
 public Select OrderBy(string field, OrderByDir dir)
 {
     this.Query.OrderByTerms.Add(new OrderByTerm(field, dir));
     return(this);
 }
Example #3
0
 /// <summary>
 /// Creates an ORDER BY term with field name and no table alias
 /// </summary>
 /// <param name="field">Name of a field to order by</param>
 /// <param name="dir">Order by direction</param>
 public OrderByTerm(string field, OrderByDir dir) : this(field, null, dir)
 {
 }
Example #4
0
 /// <summary>
 /// Creates an ORDER BY term with field name and table alias
 /// </summary>
 /// <param name="field">Name of a field to order by</param>
 /// <param name="table">The table this field belongs to</param>
 /// <param name="dir">Order by direction</param>
 public OrderByTerm(string field, FromTerm table, OrderByDir dir)
 {
     this.Field     = field;
     this.Table     = table;
     this.Direction = dir;
 }
Example #5
0
 /// <summary>Конструктор</summary>
 internal OrderBy(string field, OrderByDir dir)
 {
     Term = new OrderByTerm(field, null, dir);
 }
Example #6
0
 /// <summary>Конструктор</summary>
 internal OrderBy(string field, From table, OrderByDir dir)
 {
     Term = new OrderByTerm(field, table != null ? table.Term : null, dir);
 }