/// <summary>
        /// Paging filter for IQueryable
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="source">source query</param>
        /// <param name="pageCondition">this interface with page number and page size</param>
        /// <param name="maxPageSize">limit PageSize parameter</param>
        /// <returns></returns>
        public static IQueryable <T> FilterPage <T>(this IQueryable <T> source, IPageCondition pageCondition, int?maxPageSize = null)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }
            if (pageCondition == null)
            {
                throw new ArgumentNullException(nameof(pageCondition));
            }
            if (maxPageSize is < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(maxPageSize), "can't be bellow zero");
            }

            var pageSize = maxPageSize.HasValue ? Math.Min(maxPageSize.Value, pageCondition.PageSize) : pageCondition.PageSize;

            return(source.FilterPage(pageCondition.Page, pageSize));
        }
 public static IQueryable <T> Page <T>(this IQueryable <T> current, IPageCondition <T> condition)
 {
     return(current.Where(condition.Filter)
            .OrderBy(condition.SortDirect, condition.SortField ?? typeof(T).GetProperties(BindingFlags.Instance | BindingFlags.Public).FirstOrDefault().Name)
            .Page(condition.Page, condition.Limit));
 }