/// <summary> /// Create a fields parameter /// </summary> /// <param name="documentSearch">Document search engine</param> /// <param name="conditional">Conditional to add parameter</param> /// <param name="fieldExpressions">Expressions used to find fields name</param> /// <returns>Document search engine</returns> public static DocumentSearch <TDocument> FieldsIf <TDocument>(this DocumentSearch <TDocument> documentSearch, Func <bool> conditional, params Expression <Func <TDocument, object> >[] fieldExpressions) where TDocument : Document { Checker.IsNull(conditional); if (conditional.Invoke()) { documentSearch.Fields(fieldExpressions); } return(documentSearch); }