| | 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 && !Specification<TEntity, TResult>.IsChainDiscarded) |
| | 18 | | { |
| 9 | 19 | | previousBuilder.Specification.AddInternal(ItemType.Include, thenIncludeExpression, (int)IncludeType.ThenIncl |
| | 20 | | } |
| | 21 | | else |
| | 22 | | { |
| 10 | 23 | | Specification<TEntity, TResult>.IsChainDiscarded = true; |
| | 24 | | } |
| | 25 | |
|
| 19 | 26 | | var includeBuilder = new IncludableSpecificationBuilder<TEntity, TResult, TProperty>(previousBuilder.Specificati |
| 19 | 27 | | return includeBuilder; |
| | 28 | | } |
| | 29 | |
|
| | 30 | | public static IIncludableSpecificationBuilder<TEntity, TProperty> ThenInclude<TEntity, TPreviousProperty, TProperty> |
| | 31 | | this IIncludableSpecificationBuilder<TEntity, TPreviousProperty> previousBuilder, |
| | 32 | | Expression<Func<TPreviousProperty, TProperty>> thenIncludeExpression) |
| | 33 | | where TEntity : class |
| 23 | 34 | | => ThenInclude(previousBuilder, thenIncludeExpression, true); |
| | 35 | |
|
| | 36 | | public static IIncludableSpecificationBuilder<TEntity, TProperty> ThenInclude<TEntity, TPreviousProperty, TProperty> |
| | 37 | | this IIncludableSpecificationBuilder<TEntity, TPreviousProperty> previousBuilder, |
| | 38 | | Expression<Func<TPreviousProperty, TProperty>> thenIncludeExpression, |
| | 39 | | bool condition) |
| | 40 | | where TEntity : class |
| | 41 | | { |
| 27 | 42 | | if (condition && !Specification<TEntity>.IsChainDiscarded) |
| | 43 | | { |
| 17 | 44 | | previousBuilder.Specification.AddInternal(ItemType.Include, thenIncludeExpression, (int)IncludeType.ThenIncl |
| | 45 | | } |
| | 46 | | else |
| | 47 | | { |
| 10 | 48 | | Specification<TEntity>.IsChainDiscarded = true; |
| | 49 | | } |
| | 50 | |
|
| 27 | 51 | | var includeBuilder = new IncludableSpecificationBuilder<TEntity, TProperty>(previousBuilder.Specification); |
| 27 | 52 | | return includeBuilder; |
| | 53 | | } |
| | 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 | | where TEntity : class |
| 14 | 59 | | => ThenInclude(previousBuilder, thenIncludeExpression, true); |
| | 60 | |
|
| | 61 | | public static IIncludableSpecificationBuilder<TEntity, TResult, TProperty> ThenInclude<TEntity, TResult, TPreviousPr |
| | 62 | | this IIncludableSpecificationBuilder<TEntity, TResult, IEnumerable<TPreviousProperty>> previousBuilder, |
| | 63 | | Expression<Func<TPreviousProperty, TProperty>> thenIncludeExpression, |
| | 64 | | bool condition) |
| | 65 | | where TEntity : class |
| | 66 | | { |
| 18 | 67 | | if (condition && !Specification<TEntity, TResult>.IsChainDiscarded) |
| | 68 | | { |
| 8 | 69 | | previousBuilder.Specification.AddInternal(ItemType.Include, thenIncludeExpression, (int)IncludeType.ThenIncl |
| | 70 | | } |
| | 71 | | else |
| | 72 | | { |
| 10 | 73 | | Specification<TEntity, TResult>.IsChainDiscarded = true; |
| | 74 | | } |
| | 75 | |
|
| 18 | 76 | | var includeBuilder = new IncludableSpecificationBuilder<TEntity, TResult, TProperty>(previousBuilder.Specificati |
| 18 | 77 | | return includeBuilder; |
| | 78 | | } |
| | 79 | |
|
| | 80 | | public static IIncludableSpecificationBuilder<TEntity, TProperty> ThenInclude<TEntity, TPreviousProperty, TProperty> |
| | 81 | | this IIncludableSpecificationBuilder<TEntity, IEnumerable<TPreviousProperty>> previousBuilder, |
| | 82 | | Expression<Func<TPreviousProperty, TProperty>> thenIncludeExpression) |
| | 83 | | where TEntity : class |
| 23 | 84 | | => ThenInclude(previousBuilder, thenIncludeExpression, true); |
| | 85 | |
|
| | 86 | | public static IIncludableSpecificationBuilder<TEntity, TProperty> ThenInclude<TEntity, TPreviousProperty, TProperty> |
| | 87 | | this IIncludableSpecificationBuilder<TEntity, IEnumerable<TPreviousProperty>> previousBuilder, |
| | 88 | | Expression<Func<TPreviousProperty, TProperty>> thenIncludeExpression, |
| | 89 | | bool condition) |
| | 90 | | where TEntity : class |
| | 91 | | { |
| 27 | 92 | | if (condition && !Specification<TEntity>.IsChainDiscarded) |
| | 93 | | { |
| 17 | 94 | | previousBuilder.Specification.AddInternal(ItemType.Include, thenIncludeExpression, (int)IncludeType.ThenIncl |
| | 95 | | } |
| | 96 | | else |
| | 97 | | { |
| 10 | 98 | | Specification<TEntity>.IsChainDiscarded = true; |
| | 99 | | } |
| | 100 | |
|
| 27 | 101 | | var includeBuilder = new IncludableSpecificationBuilder<TEntity, TProperty>(previousBuilder.Specification); |
| 27 | 102 | | return includeBuilder; |
| | 103 | | } |
| | 104 | | } |