예제 #1
0
 /// <summary>
 /// 模糊匹配(like %value,自动忽略空或空文本)。
 /// </summary>
 /// <param name="operator">逻辑操作符。</param>
 /// <param name="field">列,例:aa</param>
 /// <param name="value">文本内容</param>
 /// <returns></returns>
 public virtual IWhereExpression EndsWith(WhereOperators @operator, string field, string value)
 {
     if (!string.IsNullOrEmpty(field))
     {
         return(WhereIf(_dialect.LikeGrammar(field, true, false, false), value, @operator, p => _dialect.LikeValueFilter(p, true, false, false)));
     }
     return(this);
 }
예제 #2
0
 /// <summary>
 /// 完全匹配(自动忽略空)。
 /// </summary>
 /// <param name="operator">逻辑操作符。</param>
 /// <param name="field">列,例:aa</param>
 /// <param name="value">内容</param>
 /// <returns></returns>
 public virtual IWhereExpression Equals(WhereOperators @operator, string field, object value)
 {
     if (!string.IsNullOrEmpty(field))
     {
         return(WhereIf(_dialect.PreName(field) + "={0}", value, @operator));
     }
     return(this);
 }
예제 #3
0
 /// <summary>
 /// 操作符匹配(自动忽略空)。
 /// </summary>
 /// <param name="operator">逻辑操作符。</param>
 /// <param name="field">列,例:aa</param>
 /// <param name="value">内容</param>
 /// <param name="matchOperator">匹配操作符</param>
 /// <returns></returns>
 public virtual IWhereExpression Match(WhereOperators @operator, string field, object value, MatchOpertaors matchOperator = MatchOpertaors.Equals)
 {
     if (!string.IsNullOrEmpty(field))
     {
         return(WhereIf(_dialect.PreName(field) + _dialect.MatchOperatorGrammar(EnumExtensions.GetProperty(matchOperator, "Keyword")) + "{0}", value, @operator));
     }
     return(this);
 }
예제 #4
0
 /// <summary>
 /// 生成where命令。
 /// </summary>
 /// <param name="expression">带格式串的表达式。</param>
 /// <param name="value">值,忽略null和string.Empty。</param>
 /// <param name="operator">逻辑操作符。</param>
 /// <param name="valueFilter">值过虑器,value不为null或string.Empty时。</param>
 /// <returns></returns>
 public virtual IWhereExpression WhereIf(string expression, string value, WhereOperators @operator, WhereIfValueFilterDelegate <string> valueFilter = null)
 {
     if (!string.IsNullOrEmpty(expression) && !string.IsNullOrEmpty(value))
     {
         return(Where(@operator, string.Format(expression, AddCommandParameter(valueFilter == null ? value : valueFilter(value)))));
     }
     return(this);
 }
예제 #5
0
 public Where() {
     Type = ConditionType.filter;
     lefttable = "";
     LeftField = "";
     RightField = "";
     RightTable = "";
     Operator = WhereOperators.Equal;
     Value = "";
     JoinType = JoinType.None;
     DefaultValue = "";
 }
예제 #6
0
        /// <summary>
        /// 不包含(自动忽略空)。
        /// </summary>
        /// <param name="operator">逻辑操作符。</param>
        /// <param name="field">列,例:aa</param>
        /// <param name="values">内容列表</param>
        /// <returns></returns>
        public virtual IWhereExpression NotIn(WhereOperators @operator, string field, System.Collections.IEnumerable values)
        {
            if (string.IsNullOrEmpty(field) || values == null)
            {
                return(this);
            }
            string args = ArrayToParameter(values);

            if (args.Length > 0)
            {
                return(Where(@operator, "not " + _dialect.PreName(field) + " in(" + args + ")"));
            }
            return(this);
        }
예제 #7
0
 /// <summary>
 /// 生成where命令。
 /// </summary>
 /// <param name="operator">逻辑操作符。</param>
 /// <param name="expressions">表达式。</param>
 /// <returns></returns>
 public virtual IWhereExpression Where(WhereOperators @operator, params string[] expressions)
 {
     if (expressions != null)
     {
         foreach (string expression in expressions)
         {
             if (string.IsNullOrEmpty(expression))
             {
                 continue;
             }
             string key = _dialect.ReplaceKeyword(expression);
             if (_wheres.ContainsKey(key))
             {
                 continue;
             }
             _wheres.Add(key, @operator);
         }
     }
     return(this);
 }
 /// <summary>
 /// 操作符匹配(自动忽略空)。
 /// </summary>
 /// <param name="operator">逻辑操作符。</param>
 /// <param name="field">列,例:aa</param>
 /// <param name="value">内容</param>
 /// <param name="matchOperator">匹配操作符</param>
 /// <returns></returns>
 public virtual ISelectCommandBuilder Match(WhereOperators @operator, string field, object value, MatchOpertaors matchOperator = MatchOpertaors.Equals)
 {
     _whereExpression?.Match(@operator, field, value, matchOperator);
     return(this);
 }
 /// <summary>
 /// 完全匹配(自动忽略空)。
 /// </summary>
 /// <param name="operator">逻辑操作符。</param>
 /// <param name="field">列,例:aa</param>
 /// <param name="value">内容</param>
 /// <returns></returns>
 public virtual ISelectCommandBuilder Equals(WhereOperators @operator, string field, object value)
 {
     _whereExpression?.Equals(@operator, field, value);
     return(this);
 }
 /// <summary>
 /// 生成where命令。
 /// </summary>
 /// <param name="expression">带格式串的表达式。</param>
 /// <param name="value">值,忽略null和string.Empty。</param>
 /// <param name="operator">逻辑操作符。</param>
 /// <param name="valueFilter">值过虑器,value不为null或string.Empty时。</param>
 /// <returns></returns>
 public virtual ISelectCommandBuilder WhereIf(string expression, object value, WhereOperators @operator, WhereIfValueFilterDelegate <object> valueFilter = null)
 {
     _whereExpression?.WhereIf(expression, value, @operator, valueFilter);
     return(this);
 }
 /// <summary>
 /// 生成where命令。
 /// </summary>
 /// <param name="operator">逻辑操作符。</param>
 /// <param name="expressions">表达式。</param>
 /// <returns></returns>
 public virtual ISelectCommandBuilder Where(WhereOperators @operator, params string[] expressions)
 {
     _whereExpression?.Where(@operator, expressions);
     return(this);
 }
 /// <summary>
 /// 不包含(自动忽略空)。
 /// </summary>
 /// <param name="operator">逻辑操作符。</param>
 /// <param name="field">列,例:aa</param>
 /// <param name="values">内容列表</param>
 /// <returns></returns>
 public virtual ISelectCommandBuilder NotIn(WhereOperators @operator, string field, System.Collections.IEnumerable values)
 {
     _whereExpression?.NotIn(@operator, field, values);
     return(this);
 }
예제 #13
0
        public Table AddRelation(string lefttb, string leftfld, string righttb, string rightfld, WhereOperators operators)
        {
            Relation t = new Relation(lefttb, leftfld, righttb, rightfld, operators);

            this.Relations.Add(t);
            return(this);
        }
예제 #14
0
 //private List<Where> _where;
 //public List<Where> Condition;
 public Relation(string lefttb, string leftfld, string righttb, string rightfld, WhereOperators operators)
 {
     //_where = new List<Where>();
     this.lefttable  = lefttb;
     this.LeftField  = leftfld;
     this.RightTable = righttb;
     this.RightField = rightfld;
     this.Operator   = operators;
     this.Type       = ConditionType.relation;
 }
 /// <summary>
 /// 模糊匹配(like %value%,自动忽略空或空文本)。
 /// </summary>
 /// <param name="operator">逻辑操作符。</param>
 /// <param name="field">列,例:aa</param>
 /// <param name="value">文本内容</param>
 /// <returns></returns>
 public virtual ISelectCommandBuilder Like(WhereOperators @operator, string field, string value)
 {
     _whereExpression?.Like(@operator, field, value);
     return(this);
 }
예제 #16
0
 public IFunction AddRelation(string ds, string fieldname, string relatedData, string relatedField, WhereOperators relationship)
 {
     this._arguments.Add(new ParamFields()
     {
         DataSource = ds, FieldName = fieldname, RelatedSource = relatedData, RelatedFields = relatedField, relationship = relationship
     });
     return(this);
 }
예제 #17
0
 /// <summary>
 /// 不包含(自动忽略空或空文本)。
 /// </summary>
 /// <param name="operator">逻辑操作符。</param>
 /// <param name="field">列,例:aa</param>
 /// <param name="values">文本内容列表</param>
 /// <returns></returns>
 public virtual IWhereExpression NotIn(WhereOperators @operator, string field, System.Collections.Generic.IEnumerable <string> values)
 {
     return(NotIn(@operator, field, (System.Collections.IEnumerable)values));
 }