aboutsummaryrefslogtreecommitdiffstats
path: root/src/IOL.Helpers/QueryableHelpers.cs
blob: 00f422b4eb12634fdff8231081cb8efa0f35878f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
using System;
using System.Linq;
using System.Linq.Expressions;

namespace IOL.Helpers;

public static class QueryableHelpers
{
	public static IQueryable<T> ConditionalWhere<T>(
			this IQueryable<T> source,
			Func<bool> condition,
			Expression<Func<T, bool>> predicate
	) {
		return condition() ? source.Where(predicate) : source;
	}

	public static IQueryable<T> ConditionalWhere<T>(
			this IQueryable<T> source,
			bool condition,
			Expression<Func<T, bool>> predicate
	) {
		return condition ? source.Where(predicate) : source;
	}
}