예제 #1
0
        /// <summary>
        /// Gets the search result information.
        /// </summary>
        /// <typeparam name="C"></typeparam>
        /// <param name="criteria">The criteria.</param>
        /// <param name="totalCount">The total count.</param>
        /// <returns>SearchResultInfo&lt;C&gt;.</returns>
        private SearchResultInfo <C> GetSearchResultInfo <C>(C criteria, int totalCount) where C : SearchCriteria
        {
            int pageSize  = criteria.PageSize.GetValueOrDefault(SearchConstants.DEFAULT_GRID_PAGE_SIZE);
            var pageCount = pageSize > 0 ? (totalCount / pageSize + (totalCount % pageSize > 0 ? 1 : 0)) : 0;

            var info = new SearchResultInfo <C>()
            {
                PageCount    = pageCount,
                TotalRecords = totalCount,
                CurrentPage  = criteria.CurrentPage ?? 0,
                PageSize     = pageSize,

                PreviousPageCriteria = GetPageCriteria(criteria,
                                                       (criteria.CurrentPage ?? 0) - 1,
                                                       pageCount, totalCount),

                NextPageCriteria = GetPageCriteria(criteria,
                                                   (criteria.CurrentPage ?? 0) + 1,
                                                   pageCount, totalCount)
            };


            return(info);
        }
예제 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SearchResults{T, C}"/> class.
 /// </summary>
 public SearchResults()
 {
     Info    = new SearchResultInfo <C>();
     Results = new List <T>();
 }