Skip to content

Commit 122c868

Browse files
committed
Change: ConditionalWith instead of ConditionalQuery
1 parent 0bb6961 commit 122c868

File tree

2 files changed

+65
-10
lines changed

2 files changed

+65
-10
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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+
}

src/CodeOfChaos.Extensions.EntityFrameworkCore/LinqExtensions.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,6 @@ public static IQueryable<TSource> ConditionalOrderByNotNull<TSource, TKey>(this
4949
? source.OrderBy(orderBy, comparer)
5050
: source;
5151

52-
public static IQueryable<TSource> ConditionalQuery<TSource>(this IQueryable<TSource> source, bool condition, Func<IQueryable<TSource>, IQueryable<TSource>> queryableFunc)
53-
=> condition
54-
? queryableFunc(source)
55-
: source;
56-
5752
public static IQueryable<T> ConditionalDistinct<T>(this IQueryable<T> source, bool condition)
5853
=> condition
5954
? source.Distinct()
@@ -74,11 +69,6 @@ public static IQueryable<T> ConditionalExcept<T>(this IQueryable<T> source, bool
7469
? source.Except(second)
7570
: source;
7671

77-
public static IQueryable<T> ConditionalQueryable<T>(this IQueryable<T> source, bool condition, Func<IQueryable<T>, IQueryable<T>> queryableFunc)
78-
=> condition
79-
? queryableFunc(source)
80-
: source;
81-
8272
public static IQueryable<T> ConditionalReverse<T>(this IQueryable<T> source, bool reverse)
8373
=> reverse
8474
? source.Reverse()

0 commit comments

Comments
 (0)