| | 1 | | namespace Pozitron.QuerySpecification; |
| | 2 | |
|
| | 3 | | public static class IncludableBuilderExtensions |
| | 4 | | { |
| | 5 | | public static IIncludableSpecificationBuilder<TEntity, TResult, TProperty> ThenInclude<TEntity, TResult, TPreviousPr |
| | 6 | | this IIncludableSpecificationBuilder<TEntity, TResult, TPreviousProperty> previousBuilder, |
| | 7 | | Expression<Func<TPreviousProperty, TProperty>> thenIncludeExpression) |
| | 8 | | where TEntity : class |
| 15 | 9 | | => ThenInclude(previousBuilder, thenIncludeExpression, true); |
| | 10 | |
|
| | 11 | | public static IIncludableSpecificationBuilder<TEntity, TResult, TProperty> ThenInclude<TEntity, TResult, TPreviousPr |
| | 12 | | this IIncludableSpecificationBuilder<TEntity, TResult, TPreviousProperty> previousBuilder, |
| | 13 | | Expression<Func<TPreviousProperty, TProperty>> thenIncludeExpression, |
| | 14 | | bool condition) |
| | 15 | | where TEntity : class |
| | 16 | | { |
| 19 | 17 | | if (condition && !previousBuilder.IsChainDiscarded) |
| | 18 | | { |
| 9 | 19 | | var expr = new IncludeExpression(thenIncludeExpression, typeof(TEntity), typeof(TProperty), typeof(TPrevious |
| 9 | 20 | | previousBuilder.Specification.Add(expr); |
| | 21 | | } |
| | 22 | |
|
| 19 | 23 | | var includeBuilder = new IncludableSpecificationBuilder<TEntity, TResult, TProperty>(previousBuilder.Specificati |
| 19 | 24 | | return includeBuilder; |
| | 25 | | } |
| | 26 | |
|
| | 27 | | public static IIncludableSpecificationBuilder<TEntity, TProperty> ThenInclude<TEntity, TPreviousProperty, TProperty> |
| | 28 | | this IIncludableSpecificationBuilder<TEntity, TPreviousProperty> previousBuilder, |
| | 29 | | Expression<Func<TPreviousProperty, TProperty>> thenIncludeExpression) |
| | 30 | | where TEntity : class |
| 22 | 31 | | => ThenInclude(previousBuilder, thenIncludeExpression, true); |
| | 32 | |
|
| | 33 | | public static IIncludableSpecificationBuilder<TEntity, TProperty> ThenInclude<TEntity, TPreviousProperty, TProperty> |
| | 34 | | this IIncludableSpecificationBuilder<TEntity, TPreviousProperty> previousBuilder, |
| | 35 | | Expression<Func<TPreviousProperty, TProperty>> thenIncludeExpression, |
| | 36 | | bool condition) |
| | 37 | | where TEntity : class |
| | 38 | | { |
| 26 | 39 | | if (condition && !previousBuilder.IsChainDiscarded) |
| | 40 | | { |
| 16 | 41 | | var expr = new IncludeExpression(thenIncludeExpression, typeof(TEntity), typeof(TProperty), typeof(TPrevious |
| 16 | 42 | | previousBuilder.Specification.Add(expr); |
| | 43 | | } |
| | 44 | |
|
| 26 | 45 | | var includeBuilder = new IncludableSpecificationBuilder<TEntity, TProperty>(previousBuilder.Specification, !cond |
| 26 | 46 | | return includeBuilder; |
| | 47 | | } |
| | 48 | |
|
| | 49 | | public static IIncludableSpecificationBuilder<TEntity, TResult, TProperty> ThenInclude<TEntity, TResult, TPreviousPr |
| | 50 | | this IIncludableSpecificationBuilder<TEntity, TResult, IEnumerable<TPreviousProperty>> previousBuilder, |
| | 51 | | Expression<Func<TPreviousProperty, TProperty>> thenIncludeExpression) |
| | 52 | | where TEntity : class |
| 14 | 53 | | => ThenInclude(previousBuilder, thenIncludeExpression, true); |
| | 54 | |
|
| | 55 | | public static IIncludableSpecificationBuilder<TEntity, TResult, TProperty> ThenInclude<TEntity, TResult, TPreviousPr |
| | 56 | | this IIncludableSpecificationBuilder<TEntity, TResult, IEnumerable<TPreviousProperty>> previousBuilder, |
| | 57 | | Expression<Func<TPreviousProperty, TProperty>> thenIncludeExpression, |
| | 58 | | bool condition) |
| | 59 | | where TEntity : class |
| | 60 | | { |
| 18 | 61 | | if (condition && !previousBuilder.IsChainDiscarded) |
| | 62 | | { |
| 8 | 63 | | var expr = new IncludeExpression(thenIncludeExpression, typeof(TEntity), typeof(TProperty), typeof(IEnumerab |
| 8 | 64 | | previousBuilder.Specification.Add(expr); |
| | 65 | | } |
| | 66 | |
|
| 18 | 67 | | var includeBuilder = new IncludableSpecificationBuilder<TEntity, TResult, TProperty>(previousBuilder.Specificati |
| 18 | 68 | | return includeBuilder; |
| | 69 | | } |
| | 70 | |
|
| | 71 | | public static IIncludableSpecificationBuilder<TEntity, TProperty> ThenInclude<TEntity, TPreviousProperty, TProperty> |
| | 72 | | this IIncludableSpecificationBuilder<TEntity, IEnumerable<TPreviousProperty>> previousBuilder, |
| | 73 | | Expression<Func<TPreviousProperty, TProperty>> thenIncludeExpression) |
| | 74 | | where TEntity : class |
| 23 | 75 | | => ThenInclude(previousBuilder, thenIncludeExpression, true); |
| | 76 | |
|
| | 77 | | public static IIncludableSpecificationBuilder<TEntity, TProperty> ThenInclude<TEntity, TPreviousProperty, TProperty> |
| | 78 | | this IIncludableSpecificationBuilder<TEntity, IEnumerable<TPreviousProperty>> previousBuilder, |
| | 79 | | Expression<Func<TPreviousProperty, TProperty>> thenIncludeExpression, |
| | 80 | | bool condition) |
| | 81 | | where TEntity : class |
| | 82 | | { |
| 27 | 83 | | if (condition && !previousBuilder.IsChainDiscarded) |
| | 84 | | { |
| 17 | 85 | | var expr = new IncludeExpression(thenIncludeExpression, typeof(TEntity), typeof(TProperty), typeof(IEnumerab |
| 17 | 86 | | previousBuilder.Specification.Add(expr); |
| | 87 | | } |
| | 88 | |
|
| 27 | 89 | | var includeBuilder = new IncludableSpecificationBuilder<TEntity, TProperty>(previousBuilder.Specification, !cond |
| 27 | 90 | | return includeBuilder; |
| | 91 | | } |
| | 92 | | } |