/// <summary>
        /// Retrieve items where any of the defined properties
        /// starts with any of the defined terms
        /// </summary>
        /// <param name="propertiesToSearchFor">properties defining the terms to search for</param>
        public QueryableStringSearch <T> StartsWith(params Expression <Func <T, string> >[] propertiesToSearchFor)
        {
            var propertiesToSearch = propertiesToSearchFor.Select(AlignParameter).ToArray();
            var completeExpression = QueryableStartsWithExpressionBuilder.Build(Properties, propertiesToSearch, _searchType);

            BuildExpression(completeExpression);
            return(this);
        }
        /// <summary>
        /// Retrieve items where any of the defined properties
        /// starts with any of the defined search terms
        /// </summary>
        /// <param name="terms">Term or terms to search for</param>
        public QueryableStringSearch <T> StartsWith(params string[] terms)
        {
            Expression completeExpression = null;

            foreach (var propertyToSearch in this.Properties)
            {
                var startsWithExpression = QueryableStartsWithExpressionBuilder.Build(propertyToSearch, terms, _searchType);
                completeExpression = ExpressionHelper.JoinOrExpression(completeExpression, startsWithExpression);
            }
            this.BuildExpression(completeExpression);
            return(this);
        }
示例#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 starts
 /// with any of the defined search terms
 /// </summary>
 /// <param name="terms">Term or terms to search for</param>
 public QueryableChildStringSearch <TParent, TChild> StartsWith(params string[] terms)
 {
     AppendExpression(QueryableStartsWithExpressionBuilder.Build(Properties, terms, _searchOptions.SearchType));
     return(this);
 }