public static SearchResult <T> Build(
            IEnumerable <T> items,
            PagingData pagingData)
        {
            if (pagingData == null)
            {
                throw new ArgumentNullException(nameof(pagingData));
            }
            var itemsValue = items?.ToArray() ?? throw new ArgumentNullException(nameof(items));

            return(new SearchResult <T>
            {
                Items = itemsValue,
                PagingData = pagingData
            });
        }
        public static PagingData MakeForResultCount(PagingData queryPagingData, int resultCount)
        {
            if (queryPagingData == null)
            {
                throw new ArgumentNullException(nameof(queryPagingData));
            }
            if (resultCount < 0)
            {
                throw new ArgumentException("Result count must not be less than zero", nameof(resultCount));
            }

            if (resultCount > queryPagingData.Skip)
            {
                return(new PagingData(queryPagingData.Page, queryPagingData.PageSize, resultCount));
            }

            var maxPage = resultCount <= queryPagingData.PageSize
                ? 1
                : resultCount / queryPagingData.PageSize + 1;

            return(new PagingData(maxPage, queryPagingData.PageSize, resultCount));
        }
 public SearchResult(IEnumerable <T> items, PagingData pagingData)
 {
     Items      = items?.ToArray() ?? throw new ArgumentNullException(nameof(items));
     PagingData = pagingData ?? throw new ArgumentNullException(nameof(pagingData));
 }