/// <summary> /// Create a query 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="query">Query used to make filter</param> /// <param name="instance">Instance of parameter ready to configure</param> /// <returns>Document search engine</returns> public static DocumentSearch <TDocument> QueryIf <TDocument>(this DocumentSearch <TDocument> documentSearch, Func <bool> conditional, Expression <Func <TDocument, object> > fieldExpression, Action <SearchQuery <TDocument> > query, Action <IQueryParameter <TDocument> > instance = null) where TDocument : Document { Checker.IsNull(conditional); if (conditional.Invoke()) { documentSearch.Query(fieldExpression, query, instance); } return(documentSearch); }
/// <summary> /// Create a query parameter in commom case (value to be processed using QueryField) /// </summary> /// <param name="documentSearch">Document search engine</param> /// <param name="conditional">Conditional to add parameter</param> /// <param name="values">Values to find</param> /// <returns>Document search engine</returns> public static DocumentSearch <TDocument> QueryIf <TDocument, TValue>(this DocumentSearch <TDocument> documentSearch, Func <bool> conditional, params TValue[] values) where TDocument : Document { Checker.IsNull(conditional); if (conditional.Invoke()) { documentSearch.Query(values); } return(documentSearch); }