Skip to content

Instantly share code, notes, and snippets.

@rarous
Created October 8, 2013 12:51
Show Gist options
  • Save rarous/6884185 to your computer and use it in GitHub Desktop.
Save rarous/6884185 to your computer and use it in GitHub Desktop.
public static IQueryOver<TResult, TResult> ApplyFilter<TFilter, TResult>(
this IQueryOver<TResult, TResult> query,
TFilter field,
Func<TFilter, Expression<Func<TResult, bool>>> predicate)
{
field.ToMaybe().Do(x => query.Where(predicate(x)));
return query;
}
public static IQueryOver<TResult, TResult> ApplyFilter<TField, TResult>(
this IQueryOver<TResult, TResult> query,
TField? field,
Func<TField, Expression<Func<TResult, bool>>> predicate)
where TField : struct
{
field.ToMaybe().Do(x => query.Where(predicate(x)));
return query;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment