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)); } }
/// <summary>Аналог конструкции SELECT ... ORDER BY</summary> public Select OrderBy(string field, OrderByDir dir) { this.Query.OrderByTerms.Add(new OrderByTerm(field, dir)); return(this); }
/// <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) { }
/// <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; }
/// <summary>Конструктор</summary> internal OrderBy(string field, OrderByDir dir) { Term = new OrderByTerm(field, null, dir); }
/// <summary>Конструктор</summary> internal OrderBy(string field, From table, OrderByDir dir) { Term = new OrderByTerm(field, table != null ? table.Term : null, dir); }