Esempio n. 1
0
 public ParamDelete Where(Action<ConditionBuilder> builder)
 {
     var cb = new ConditionBuilder();
     builder(cb);
     data.Where.Add(cb.c);
     return this;
 }
Esempio n. 2
0
        public ParamUpdate Where(string column, object value)
        {
            var cb = new ConditionBuilder().And(column, value).Symbol("equal");

            data.Where.Add(cb.c);
            return(this);
        }
Esempio n. 3
0
        public ParamUpdate Where(Action <ConditionBuilder> builder)
        {
            var cb = new ConditionBuilder();

            builder(cb);
            data.Where.Add(cb.c);
            return(this);
        }
        void BuildCondition(ConditionBuilder builder, JToken c)
        {
            Func <string, string, string> GetPropertyValue = (name, defaults) => (c.Value <string>(name) ?? defaults).Trim("\r\n ".ToCharArray());
            var column = GetPropertyValue("column", string.Empty);

            if (string.IsNullOrEmpty(column))
            {
                throw new Exception("配置中缺少column节点!");
            }

            var valuestr = GetPropertyValue("values", string.Format("{{{0}}}", column.Split('.').Last())); //set defaults
            var values   = valuestr.Split(',');

            var symbol = GetPropertyValue("symbol", "equal");
            var ignore = GetPropertyValue("ignore", string.Empty);
            var join   = GetPropertyValue("join", "and");

            var objValues = new object[values.Length];//handle values {value}[string] getdate

            for (var i = 0; i < values.Length; i++)
            {
                var v = values[i];
                if (v.StartsWith("{") && v.EndsWith("}"))
                {
                    objValues[i] = this[v.Substring(1, v.Length - 2)];
                }
                else if (v.StartsWith("[") && v.EndsWith("]"))
                {
                    objValues[i] = v.Substring(1, v.Length - 1);
                }
                else
                {
                    objValues[i] = string.Format("{0}", v);
                }
            }

            if (!string.IsNullOrEmpty(ignore))
            {
                if (App.ConditionIgnorer.ContainsKey(ignore))
                {
                    builder.Ignore(App.ConditionIgnorer[ignore]);
                }
                else
                {
                    throw new Exception(string.Format("使用了未定义的条件忽略选项{0}!", ignore));
                }
            }

            if (join == "or")
            {
                builder.Or(column, objValues).Symbol(symbol);
            }
            else
            {
                builder.And(column, objValues).Symbol(symbol);
            }
        }
        void BuildCondition(ConditionBuilder builder, JToken c)
        {
            Func<string, string, string> GetPropertyValue = (name, defaults) => (c.Value<string>(name) ?? defaults).Trim("\r\n ".ToCharArray());
            var column = GetPropertyValue("column",string.Empty);
            if (string.IsNullOrEmpty(column))
                throw new Exception("配置中缺少column节点!");

            var valuestr = GetPropertyValue("values", string.Format("{{{0}}}", column.Split('.').Last())); //set defaults
            var values = valuestr.Split(',');
            
            var symbol = GetPropertyValue("symbol","equal");
            var ignore = GetPropertyValue("ignore",string.Empty);
            var join = GetPropertyValue("join","and");

            var objValues = new object[values.Length];//handle values {value}[string] getdate
            for (var i = 0; i < values.Length; i++)
            {
                var v = values[i];
                if (v.StartsWith("{") && v.EndsWith("}"))
                    objValues[i] = this[v.Substring(1, v.Length - 2)];
                else if (v.StartsWith("[") && v.EndsWith("]"))
                    objValues[i] = v.Substring(1, v.Length - 1);
                else
                    objValues[i] = string.Format("{0}", v);
            }

            if (!string.IsNullOrEmpty(ignore))
            {
                if (App.ConditionIgnorer.ContainsKey(ignore))
                    builder.Ignore(App.ConditionIgnorer[ignore]);
                else
                    throw new Exception(string.Format("使用了未定义的条件忽略选项{0}!",ignore));
            }

            if (join == "or")
                builder.Or(column, objValues).Symbol(symbol);
            else
                builder.And(column, objValues).Symbol(symbol);
        }
Esempio n. 6
0
 public ParamDelete Where(string column, object value)
 {
     var cb = new ConditionBuilder().And(column, value).Symbol("equal");
     data.Where.Add(cb.c);
     return this;
 }
 private string GetDateRangeSql(string column,string value)
 {
     var maker = App.DictSql[DbType.SqlServer, "DateRange"];
     var cb = new ConditionBuilder().Symbol("daterange");
     return "and " + maker.Handler(cb.And(column, value).c);
 }