Skip to content

Instantly share code, notes, and snippets.

@detroitpro
Created June 2, 2010 04:52
Show Gist options
  • Save detroitpro/421948 to your computer and use it in GitHub Desktop.
Save detroitpro/421948 to your computer and use it in GitHub Desktop.
public static class QueryableExtensions {
public static IQueryable<TSource> WhereIf<TSource>(
this IQueryable<TSource> source, bool condition,
Expression<Func<TSource, bool>> predicate) {
if (condition)
return source.Where(predicate);
else
return source;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment