1 2 3 4 5 6 7 8 9 10 11 12 13 14
namespace marlin.web.Util; using System.Linq.Expressions; public static class IQueryableExtensions { public static IQueryable<T> WhereIf<T>( this IQueryable<T> self, bool cond, Expression<Func<T, bool>> predicate) { return cond ? self.Where(predicate) : self; } }