|
| 1 | +// --------------------------------------------------------------------------------------------------------------------- |
| 2 | +// Imports |
| 3 | +// --------------------------------------------------------------------------------------------------------------------- |
| 4 | +using System.Diagnostics; |
| 5 | + |
| 6 | +namespace Microsoft.EntityFrameworkCore; |
| 7 | +// --------------------------------------------------------------------------------------------------------------------- |
| 8 | +// Code |
| 9 | +// --------------------------------------------------------------------------------------------------------------------- |
| 10 | +public static class LinqConditionalWithExtensions { |
| 11 | + |
| 12 | + [DebuggerStepThrough] |
| 13 | + public static IQueryable<T> ConditionalWith<T>(this IQueryable<T> source, bool condition, Func<IQueryable<T>, IQueryable<T>> query) |
| 14 | + => condition |
| 15 | + ? query(source) |
| 16 | + : source; |
| 17 | + |
| 18 | + [DebuggerStepThrough] |
| 19 | + public static IQueryable<T> ConditionalWith<T, T0>(this IQueryable<T> source, bool condition, Func<IQueryable<T>, T0, IQueryable<T>> query, T0 arg0) |
| 20 | + => condition |
| 21 | + ? query(source, arg0) |
| 22 | + : source; |
| 23 | + |
| 24 | + [DebuggerStepThrough] |
| 25 | + public static IQueryable<T> ConditionalWith<T, T0, T1>(this IQueryable<T> source, bool condition, Func<IQueryable<T>, T0, T1, IQueryable<T>> query, T0 arg0, T1 arg1) |
| 26 | + => condition |
| 27 | + ? query(source, arg0, arg1) |
| 28 | + : source; |
| 29 | + |
| 30 | + [DebuggerStepThrough] |
| 31 | + public static IQueryable<T> ConditionalWith<T, T0, T1, T2>(this IQueryable<T> source, bool condition, Func<IQueryable<T>, T0, T1, T2, IQueryable<T>> query, T0 arg0, T1 arg1, T2 arg2) |
| 32 | + => condition |
| 33 | + ? query(source, arg0, arg1, arg2) |
| 34 | + : source; |
| 35 | + |
| 36 | + [DebuggerStepThrough] |
| 37 | + public static IQueryable<T> ConditionalWith<T, T0, T1, T2, T3>(this IQueryable<T> source, bool condition, Func<IQueryable<T>, T0, T1, T2, T3, IQueryable<T>> query, T0 arg0, T1 arg1, T2 arg2, T3 arg3) |
| 38 | + => condition |
| 39 | + ? query(source, arg0, arg1, arg2, arg3) |
| 40 | + : source; |
| 41 | + |
| 42 | + [DebuggerStepThrough] |
| 43 | + public static IQueryable<T> ConditionalWith<T, T0, T1, T2, T3, T4>(this IQueryable<T> source, bool condition, Func<IQueryable<T>, T0, T1, T2, T3, T4, IQueryable<T>> query, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4) |
| 44 | + => condition |
| 45 | + ? query(source, arg0, arg1, arg2, arg3, arg4) |
| 46 | + : source; |
| 47 | + |
| 48 | + [DebuggerStepThrough] |
| 49 | + public static IQueryable<T> ConditionalWith<T, T0, T1, T2, T3, T4, T5>(this IQueryable<T> source, bool condition, Func<IQueryable<T>, T0, T1, T2, T3, T4, T5, IQueryable<T>> query, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) |
| 50 | + => condition |
| 51 | + ? query(source, arg0, arg1, arg2, arg3, arg4, arg5) |
| 52 | + : source; |
| 53 | + |
| 54 | + [DebuggerStepThrough] |
| 55 | + public static IQueryable<T> ConditionalWith<T, T0, T1, T2, T3, T4, T5, T6>(this IQueryable<T> source, bool condition, Func<IQueryable<T>, T0, T1, T2, T3, T4, T5, T6, IQueryable<T>> query, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6) |
| 56 | + => condition |
| 57 | + ? query(source, arg0, arg1, arg2, arg3, arg4, arg5, arg6) |
| 58 | + : source; |
| 59 | + |
| 60 | + [DebuggerStepThrough] |
| 61 | + public static IQueryable<T> ConditionalWith<T, T0, T1, T2, T3, T4, T5, T6, T7>(this IQueryable<T> source, bool condition, Func<IQueryable<T>, T0, T1, T2, T3, T4, T5, T6, T7, IQueryable<T>> query, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7) |
| 62 | + => condition |
| 63 | + ? query(source, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) |
| 64 | + : source; |
| 65 | +} |
0 commit comments