/// <summary>
 /// Filters a sequence of values based on a query string.
 /// </summary>
 /// <typeparam name="T">The element type of the sequence.</typeparam>
 /// <param name="source">An <see cref="IQueryable{T}"/> to filter.</param>
 /// <param name="filterQuery">A query string to be interpreted as a filter to test each element for a condition.</param>
 /// <returns>An <see cref="IQueryable{T}"/> that contains elements from the input sequence that satisfy the condition specified by filter query.</returns>
 /// <exception cref="ArgumentNullException">Thrown when source is null.</exception>
 /// <exception cref="ArgumentException">Thrown when filter query is invalid.</exception>
 public static IQueryable <T> Filter <T>(this IQueryable <T> source, string filterQuery)
 {
     return(QueryableFilter.TryParse(filterQuery, out QueryableFilter <T> filter)
         ? source.Filter(filter)
         : throw new ArgumentException("Invalid filter query", nameof(filterQuery)));
 }
Пример #2
0
 public static IQueryable <TData> Filter <TModel, TData>(this IQueryable <TData> source, IMapper mapper, string filterQuery)
 {
     return(QueryableFilter.TryParse(filterQuery, out QueryableFilter <TModel> filter)
         ? source.Filter(mapper, filter)
         : throw new ArgumentException("Invalid filter query", nameof(filterQuery)));
 }