/// <summary>
        /// Retrieve items where any of the defined properties
        /// ends with any of the defined search terms
        /// </summary>
        /// <param name="terms">Term or terms to search for</param>
        public QueryableStringSearch <T> EndsWith(params string[] terms)
        {
            var endsWithExpression = QueryableEndsWithExpressionBuilder.Build(this.Properties, terms, _searchType);

            this.BuildExpression(endsWithExpression);
            return(this);
        }
        /// <summary>
        /// Retrieve items where any of the defined properties
        /// ends with any of the defined terms
        /// </summary>
        /// <param name="propertiesToSearchFor">properties defining the terms to search for</param>
        public QueryableStringSearch <T> EndsWith(params Expression <Func <T, string> >[] propertiesToSearchFor)
        {
            var propertiesToSearch = propertiesToSearchFor.Select(AlignParameter).ToArray();
            var endsWithExpression = QueryableEndsWithExpressionBuilder.Build(Properties, propertiesToSearch, _searchType);

            BuildExpression(endsWithExpression);
            return(this);
        }
Ejemplo n.º 3
0
        public static Expression Build <T>(Expression <Func <T, string> >[] propertiesToSearch, ICollection <string> searchTerms, SearchType searchType)
        {
            Expression result = null;

            foreach (var propertyToSearch in propertiesToSearch)
            {
                var containsExpression = Build(propertyToSearch, searchTerms, searchType);
                result = ExpressionHelper.JoinOrExpression(result, containsExpression);
            }

            if (searchType == SearchType.WholeWords)
            {
                var terms = searchTerms.ToArray();
                var startsWithExpression = QueryableStartsWithExpressionBuilder.Build(propertiesToSearch, terms, searchType);
                result = ExpressionHelper.JoinOrExpression(result, startsWithExpression);
                var endsWithExpression = QueryableEndsWithExpressionBuilder.Build(propertiesToSearch, terms, searchType);
                result = ExpressionHelper.JoinOrExpression(result, endsWithExpression);

                var equalsExpression = QueryableEqualsExpressionBuilder.Build(propertiesToSearch, terms);
                result = ExpressionHelper.JoinOrExpression(result, equalsExpression);
            }

            return(result);
        }
 /// <summary>
 /// Retrieve items where any of the defined properties ends
 /// with any of the defined search terms
 /// </summary>
 /// <param name="terms">Term or terms to search for</param>
 public QueryableChildStringSearch <TParent, TChild> EndsWith(params string[] terms)
 {
     AppendExpression(QueryableEndsWithExpressionBuilder.Build(Properties, terms, _searchOptions.SearchType));
     return(this);
 }