DynamicWhere.ex
DynamicWhere.exv2.1.0·docs

Direction

Direction is the sort direction for an OrderBy. It maps directly onto LINQ's OrderBy / OrderByDescending and SQL's ASC / DESC.

Values

ValueDescriptionLINQ equivalentSQL equivalent
AscendingSort A → Z, 0 → 9, oldest → newest.OrderBy(x => x.Field)ORDER BY Field ASC
DescendingSort Z → A, 9 → 0, newest → oldest.OrderByDescending(x => x.Field)ORDER BY Field DESC
Note
Ascending is the default if you build an OrderBy in C# without setting Direction explicitly.

JSON — single order

{
  "sort": 1,
  "field": "CreatedAt",
  "direction": "Descending"
}

JSON — multiple orders

Multiple OrderBy entries are applied in Sort order (lower runs first, becoming the primary sort key).

[
  { "sort": 1, "field": "LastName",  "direction": "Ascending" },
  { "sort": 2, "field": "FirstName", "direction": "Ascending" },
  { "sort": 3, "field": "CreatedAt", "direction": "Descending" }
]

Equivalent SQL (illustrative):

ORDER BY LastName ASC, FirstName ASC, CreatedAt DESC

C# usage

using DynamicWhere.ex.Enums;

var orders = new List<OrderBy>
{
    new OrderBy { Sort = 1, Field = "LastName",  Direction = Direction.Ascending },
    new OrderBy { Sort = 2, Field = "FirstName", Direction = Direction.Ascending },
    new OrderBy { Sort = 3, Field = "CreatedAt", Direction = Direction.Descending },
};

var query = db.Customers.Order(orders);

Used by

  • OrderBy — the class that carries Direction.
  • .Order<T> → the extension method that applies an OrderBy (or a list of them) to an IQueryable.
  • Filter, Segment, and Summary — all expose an Orders list.