/// <summary> /// Retrieve items where any of the defined terms are contained /// within any of the defined properties /// </summary> /// <param name="terms">Term or terms to search for</param> public EnumerableStringSearch <T> Containing(params string[] terms) { Ensure.ArgumentNotNull(terms, "terms"); if (!terms.Any() || !this.Properties.Any()) { return(null); } var validSearchTerms = terms.Where(s => !String.IsNullOrWhiteSpace(s)).ToArray(); if (!validSearchTerms.Any()) { return(null); } foreach (var validSearchTerm in validSearchTerms) { this._containingSearchTerms.Add(validSearchTerm); } Expression orExpression = EnumerableContainsExpressionBuilder.Build(Properties, validSearchTerms, _searchOptions); this.BuildExpression(orExpression); return(this); }
/// <summary> /// Retrieve items where any of the defined terms are contained /// within any of the defined properties /// </summary> /// <param name="terms">Term or terms to search for</param> public EnumerableChildStringSearch <TParent, TChild> Containing(params string[] terms) { var validSearchTerms = terms.Where(s => !String.IsNullOrWhiteSpace(s)).ToArray(); if (validSearchTerms.Any()) { var containingExpression = EnumerableContainsExpressionBuilder.Build(this.Properties, validSearchTerms, _searchOptions); this.AppendExpression(containingExpression); } return(this); }
/// <summary> /// Retrieve items where any of the defined terms are contained /// within any of the defined properties /// </summary> /// <param name="propertiesToSearchFor">Property or properties to search against</param> public EnumerableStringSearch <T> Containing(params Expression <Func <T, string> >[] propertiesToSearchFor) { Expression finalExpression = null; foreach (var stringProperty in propertiesToSearchFor) { var containsProperty = AlignParameter(stringProperty); foreach (var propertyToSearch in Properties) { var containsExpression = EnumerableContainsExpressionBuilder.Build(propertyToSearch, containsProperty); finalExpression = ExpressionHelper.JoinOrExpression(finalExpression, containsExpression); } } BuildExpression(finalExpression); return(this); }