| | 1 | | using System.Diagnostics; |
| | 2 | |
|
| | 3 | | namespace Pozitron.QuerySpecification; |
| | 4 | |
|
| | 5 | | /// <summary> |
| | 6 | | /// Represents a where expression used in a specification. |
| | 7 | | /// </summary> |
| | 8 | | /// <typeparam name="T">The type of the entity.</typeparam> |
| | 9 | | public sealed class WhereExpression<T> |
| | 10 | | { |
| | 11 | | /// <summary> |
| | 12 | | /// Gets the filter expression. |
| | 13 | | /// </summary> |
| 3 | 14 | | public Expression<Func<T, bool>> Filter { get; } |
| | 15 | |
|
| | 16 | | /// <summary> |
| | 17 | | /// Initializes a new instance of the <see cref="WhereExpression{T}"/> class. |
| | 18 | | /// </summary> |
| | 19 | | /// <param name="filter">The filter expression.</param> |
| 9 | 20 | | public WhereExpression(Expression<Func<T, bool>> filter) |
| | 21 | | { |
| | 22 | | Debug.Assert(filter is not null); |
| 9 | 23 | | Filter = filter; |
| 9 | 24 | | } |
| | 25 | | } |
| | 26 | |
|
| | 27 | | /// <summary> |
| | 28 | | /// Represents a compiled where expression used in a specification. |
| | 29 | | /// </summary> |
| | 30 | | /// <typeparam name="T">The type of the entity.</typeparam> |
| | 31 | | public sealed class WhereExpressionCompiled<T> |
| | 32 | | { |
| | 33 | | /// <summary> |
| | 34 | | /// Gets the compiled filter function. |
| | 35 | | /// </summary> |
| | 36 | | public Func<T, bool> Filter { get; } |
| | 37 | |
|
| | 38 | | /// <summary> |
| | 39 | | /// Initializes a new instance of the <see cref="WhereExpressionCompiled{T}"/> class. |
| | 40 | | /// </summary> |
| | 41 | | /// <param name="filter">The compiled filter function.</param> |
| | 42 | | public WhereExpressionCompiled(Func<T, bool> filter) |
| | 43 | | { |
| | 44 | | Debug.Assert(filter is not null); |
| | 45 | | Filter = filter; |
| | 46 | | } |
| | 47 | | } |