/// <summary>
        ///
        /// </summary>
        /// <param name="searchConditions"></param>
        /// <param name="searchOrders"></param>
        public virtual void FillSearchConditions(IList <ISearchExpression> searchConditions, IList <ISearchOrder> searchOrders)
        {
            if (Order.HasValue)
            {
                if (Order.Value)
                {
                    searchOrders.Add(SearchOrder.Asc(PropertyNameToSearch));
                }
                else
                {
                    searchOrders.Add(SearchOrder.Desc(PropertyNameToSearch));
                }
            }

            if (IsNull)
            {
                if (!IsNot)
                {
                    if (SearchNullUseFull)
                    {
                        searchConditions.Add(SearchExpression.IsNull(PropertyNameToSearch));
                    }
                    else
                    {
                        string[] ss = this.Navigator.Split(new char[] { '.', ':' }, StringSplitOptions.RemoveEmptyEntries);
                        searchConditions.Add(SearchExpression.IsNull(ss[0]));
                    }
                }
                else
                {
                    searchConditions.Add(SearchExpression.IsNotNull(PropertyNameToSearch));
                }
            }
            else
            {
                if (SelectedDataValue1 == null && SelectedDataValue2 == null)
                {
                    return;
                }

                if (SelectedDataValue1 != null && SelectedDataValue2 == null)
                {
                    if (!IsNot)
                    {
                        searchConditions.Add(SearchExpression.Ge(PropertyNameToSearch, this.SelectedDataValue1));
                    }
                    else
                    {
                        searchConditions.Add(SearchExpression.Lt(PropertyNameToSearch, this.SelectedDataValue1));
                    }
                }
                else if (SelectedDataValue1 == null && SelectedDataValue2 != null)
                {
                    if (!IsNot)
                    {
                        searchConditions.Add(SearchExpression.Le(PropertyNameToSearch, this.SelectedDataValue2));
                    }
                    else
                    {
                        searchConditions.Add(SearchExpression.Gt(PropertyNameToSearch, this.SelectedDataValue2));
                    }
                }
                else
                {
                    if (!IsNot)
                    {
                        searchConditions.Add(SearchExpression.And(SearchExpression.Ge(PropertyNameToSearch, this.SelectedDataValue1),
                                                                  SearchExpression.Le(PropertyNameToSearch, this.SelectedDataValue2)));
                    }
                    else
                    {
                        searchConditions.Add(SearchExpression.Or(SearchExpression.Lt(PropertyNameToSearch, this.SelectedDataValue1),
                                                                 SearchExpression.Gt(PropertyNameToSearch, this.SelectedDataValue2)));
                    }
                }
            }

            if (!string.IsNullOrEmpty(this.AdditionalSearchExpression))
            {
                searchConditions.Add(SearchExpression.Parse(this.AdditionalSearchExpression));
            }
        }
Exemple #2
0
        private ISearchExpression ParseSimpleExpression()
        {
            string            s1 = ParseWordExpression();
            string            s2;
            ISearchExpression exp;

            switch (this.token)
            {
            case TokenType.Eq:
                this.MoveNext();
                s2 = ParseWordExpression();
                return(SearchExpression.Eq(s1, s2));

            case TokenType.NotEq:
                this.MoveNext();
                s2 = ParseWordExpression();
                return(SearchExpression.NotEq(s1, s2));

            case TokenType.EqProperty:
                this.MoveNext();
                s2 = ParseWordExpression();
                return(SearchExpression.EqProperty(s1, s2));

            case TokenType.Gt:
                this.MoveNext();
                s2 = ParseWordExpression();
                return(SearchExpression.Gt(s1, s2));

            case TokenType.Ge:
                this.MoveNext();
                s2 = ParseWordExpression();
                return(SearchExpression.Ge(s1, s2));

            case TokenType.Lt:
                this.MoveNext();
                s2 = ParseWordExpression();
                return(SearchExpression.Lt(s1, s2));

            case TokenType.Le:
                this.MoveNext();
                s2 = ParseWordExpression();
                return(SearchExpression.Le(s1, s2));

            case TokenType.InG:
                this.MoveNext();
                s2 = ParseWordExpression();
                return(SearchExpression.InG(s1, GetArrayList(s2)));

            case TokenType.GInG:
                this.MoveNext();
                s2 = ParseWordExpression();
                return(SearchExpression.GInG(s1, GetArrayList(s2)));

            case TokenType.Like:
                this.MoveNext();
                s2 = ParseWordExpression();
                return(SearchExpression.Like(s1, s2));

            case TokenType.IsNull:
                exp = SearchExpression.IsNull(s1);
                this.MoveNext();
                return(exp);

            case TokenType.IsNotNull:
                exp = SearchExpression.IsNotNull(s1);
                this.MoveNext();
                return(exp);

            case TokenType.Sql:
                exp = SearchExpression.Sql(s1);
                this.MoveNext();
                return(exp);

            default:
                throw new ArgumentException("Invalid token of " + token);
            }
        }