Direction
Direction is the sort direction for an OrderBy. It maps directly onto LINQ's OrderBy / OrderByDescending and SQL's ASC / DESC.
Values
| Value | Description | LINQ equivalent | SQL equivalent |
|---|---|---|---|
Ascending | Sort A → Z, 0 → 9, oldest → newest. | OrderBy(x => x.Field) | ORDER BY Field ASC |
Descending | Sort 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 DESCC# 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 carriesDirection.- .Order<T> → the extension method that applies an
OrderBy(or a list of them) to anIQueryable. Filter,Segment, andSummary— all expose anOrderslist.
Related
- Order example → end-to-end JSON cookbook.
- PageBy → paginate the ordered result.