/// <summary> /// Create a facet field parameter /// </summary> /// <param name="documentSearch">Document search engine</param> /// <param name="conditional">Conditional to add parameter</param> /// <param name="fieldExpression">Expression used to find field name</param> /// <param name="instance">Instance of facet ready to configure</param> /// <returns>Document search engine</returns> public static DocumentSearch <TDocument> FacetFieldIf <TDocument>(this DocumentSearch <TDocument> documentSearch, Func <bool> conditional, Expression <Func <TDocument, object> > fieldExpression, Action <IFacetFieldParameter <TDocument> > instance = null) where TDocument : Document { Checker.IsNull(conditional); if (conditional.Invoke()) { documentSearch.FacetField(fieldExpression, instance); } return(documentSearch); }