| | 1 | | using System.Diagnostics; |
| | 2 | |
|
| | 3 | | namespace Pozitron.QuerySpecification; |
| | 4 | |
|
| | 5 | | /// <summary> |
| | 6 | | /// Represents an order expression used in a specification. |
| | 7 | | /// </summary> |
| | 8 | | /// <typeparam name="T">The type of the entity.</typeparam> |
| | 9 | | public sealed class OrderExpression<T> |
| | 10 | | { |
| | 11 | | /// <summary> |
| | 12 | | /// Gets the key selector expression. |
| | 13 | | /// </summary> |
| 10 | 14 | | public Expression<Func<T, object?>> KeySelector { get; } |
| | 15 | |
|
| | 16 | | /// <summary> |
| | 17 | | /// Gets the type of the order. |
| | 18 | | /// </summary> |
| 54 | 19 | | public OrderType Type { get; } |
| | 20 | |
|
| | 21 | | /// <summary> |
| | 22 | | /// Initializes a new instance of the <see cref="OrderExpression{T}"/> class. |
| | 23 | | /// </summary> |
| | 24 | | /// <param name="keySelector">The key selector expression.</param> |
| | 25 | | /// <param name="type">The type of the order.</param> |
| 186 | 26 | | public OrderExpression(Expression<Func<T, object?>> keySelector, OrderType type) |
| | 27 | | { |
| | 28 | | Debug.Assert(keySelector is not null); |
| 186 | 29 | | KeySelector = keySelector; |
| 186 | 30 | | Type = type; |
| 186 | 31 | | } |
| | 32 | | } |
| | 33 | |
|
| | 34 | | /// <summary> |
| | 35 | | /// Represents a compiled order expression used in a specification. |
| | 36 | | /// </summary> |
| | 37 | | /// <typeparam name="T">The type of the entity.</typeparam> |
| | 38 | | public sealed class OrderExpressionCompiled<T> |
| | 39 | | { |
| | 40 | | /// <summary> |
| | 41 | | /// Gets the compiled key selector function. |
| | 42 | | /// </summary> |
| | 43 | | public Func<T, object?> KeySelector { get; } |
| | 44 | |
|
| | 45 | | /// <summary> |
| | 46 | | /// Gets the type of the order. |
| | 47 | | /// </summary> |
| | 48 | | public OrderType Type { get; } |
| | 49 | |
|
| | 50 | | /// <summary> |
| | 51 | | /// Initializes a new instance of the <see cref="OrderExpressionCompiled{T}"/> class. |
| | 52 | | /// </summary> |
| | 53 | | /// <param name="keySelector">The compiled key selector function.</param> |
| | 54 | | /// <param name="type">The type of the order.</param> |
| | 55 | | public OrderExpressionCompiled(Func<T, object?> keySelector, OrderType type) |
| | 56 | | { |
| | 57 | | Debug.Assert(keySelector is not null); |
| | 58 | | KeySelector = keySelector; |
| | 59 | | Type = type; |
| | 60 | | } |
| | 61 | | } |