/// <summary> /// Create a limit and a offset parameters /// </summary> /// <param name="documentSearch">Document search engine</param> /// <param name="itemsPerPage">Quantity of items in one page</param> /// <param name="currentPage">Current page</param> /// <returns>Document search engine</returns> public static DocumentSearch <TDocument> Page <TDocument>(this DocumentSearch <TDocument> documentSearch, long itemsPerPage, long currentPage) where TDocument : Document { documentSearch.Limit(itemsPerPage); documentSearch.Offset((currentPage - 1) * itemsPerPage); return(documentSearch); }
/// <summary> /// Create a limit parameter /// </summary> /// <param name="documentSearch">Document search engine</param> /// <param name="conditional">Conditional to add parameter</param> /// <param name="value">Value of limit</param> /// <returns>Document search engine</returns> public static DocumentSearch <TDocument> LimitIf <TDocument>(this DocumentSearch <TDocument> documentSearch, Func <bool> conditional, long value) where TDocument : Document { Checker.IsNull(conditional); if (conditional.Invoke()) { documentSearch.Limit(value); } return(documentSearch); }