/// <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 (string.IsNullOrEmpty(this.Navigator)) //{ // searchConditions.Add(SearchExpression.IsNull(PropertyNameToSearch)); //} //else //{ // // 为空的话,只去最前面一个 // string[] ss = this.Navigator.Split(new char[] { '.', ':' }, StringSplitOptions.RemoveEmptyEntries); // searchConditions.Add(SearchExpression.IsNull(ss[0])); //} if (SearchNullUseFull || string.IsNullOrEmpty(this.Navigator)) { searchConditions.Add(SearchExpression.IsNull(PropertyNameToSearch)); } else { if (string.IsNullOrEmpty(this.Navigator)) { throw new ArgumentException("When SearchNullUseFull is false, it will use Navigator's first part, so navigator must not null!"); } string[] ss = this.Navigator.Split(new char[] { '.', ':' }, StringSplitOptions.RemoveEmptyEntries); searchConditions.Add(SearchExpression.IsNull(ss[0])); } } else { searchConditions.Add(SearchExpression.IsNotNull(PropertyNameToSearch)); } } else { IMultiDataValueControl mdc = this.Control as IMultiDataValueControl; if (mdc != null) { if (this.SelectedDataValues.Count == 0) { return; } if (!this.UseFuzzySearch.HasValue) { if (this.CanSelectFuzzySearch && mdc.SelectedDataValues.Count == 1) { if (!IsNot) { searchConditions.Add(SearchExpression.Like(PropertyNameToSearch, mdc.SelectedDataValues[0])); } else { searchConditions.Add(SearchExpression.NotLike(PropertyNameToSearch, mdc.SelectedDataValues[0])); } } else { if (!IsNot) { searchConditions.Add(SearchExpression.InG(PropertyNameToSearch, mdc.SelectedDataValues)); } else { searchConditions.Add(SearchExpression.NotInG(PropertyNameToSearch, mdc.SelectedDataValues)); } } } else if (this.UseFuzzySearch.Value) { if (!IsNot) { searchConditions.Add(SearchExpression.GInG(PropertyNameToSearch, mdc.SelectedDataValues)); } else { searchConditions.Add(SearchExpression.NotGInG(PropertyNameToSearch, mdc.SelectedDataValues)); } } else { if (!IsNot) { searchConditions.Add(SearchExpression.InG(PropertyNameToSearch, mdc.SelectedDataValues)); } else { searchConditions.Add(SearchExpression.NotInG(PropertyNameToSearch, mdc.SelectedDataValues)); } } } else { if (this.SelectedDataValue == null) { return; } if (this.CanSelectFuzzySearch && (!this.UseFuzzySearch.HasValue || this.UseFuzzySearch.Value)) { string s = this.SelectedDataValue.ToString(); if (!IsNot) { searchConditions.Add(SearchExpression.Like(PropertyNameToSearch, s)); } else { searchConditions.Add(SearchExpression.NotLike(PropertyNameToSearch, s)); } } else { if (!IsNot) { searchConditions.Add(SearchExpression.Eq(PropertyNameToSearch, this.SelectedDataValue)); } else { searchConditions.Add(SearchExpression.NotEq(PropertyNameToSearch, this.SelectedDataValue)); } } } } if (!string.IsNullOrEmpty(this.AdditionalSearchExpression)) { searchConditions.Add(SearchExpression.Parse(this.AdditionalSearchExpression)); } }
/// <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)); } }
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); } }