コード例 #1
0
        protected IUpdateBuilder BuilderParse(ParamUpdate param)
        {
            var data          = param.GetData();
            var FromTable     = data.Update.Length == 0 ? typeof(T).Name : data.Update.Replace("\r\n", "").Trim();
            var updateBuilder = db.Update(FromTable);

            var dict = GetPersonDateForUpdate();

            //查询出不包含 CreatePerson,CreateDate,UpdatePerson,UpdateDate 的字段并赋值
            foreach (var column in data.Columns.Where(column => !dict.ContainsKey(column.Key)))
            {
                updateBuilder.Column(column.Key, column.Value);
            }

            //
            //获取程序集 反射出程序集下特定Model类
            System.Reflection.Assembly t = System.Reflection.Assembly.Load("Zephyr.Web");
            Type TypeModel  = t.GetType("Zephyr.Models." + FromTable);
            var  properties = Zephyr.Utils.ZReflection.GetProperties(TypeModel);//获取所有属性

            //
            //查询出包含 CreatePerson,CreateDate,UpdatePerson,UpdateDate 并给予这些字段赋值
            foreach (var item in dict.Where(item => properties.ContainsKey(item.Key)))
            {
                updateBuilder.Column(item.Key, item.Value);
            }

            updateBuilder.Where(data.WhereSql);

            return(updateBuilder);
        }
コード例 #2
0
        protected IUpdateBuilder BuilderParse(ParamUpdate param)
        {
            var data = param.GetData();
            var from = data.Update.Length == 0 ? typeof(T).Name : data.Update;

            var updateBuilder = db.Update(from);

            var dict = App.GetDefaultForUpdate();

            foreach (var column in data.Columns.Where(column => !dict.ContainsKey(column.Key)))
            {
                updateBuilder.Column(column.Key, column.Value);
            }

            var properties = ReflectionHelper.GetProperties(typeof(T));

            foreach (var item in dict.Where(item => properties.ContainsKey(item.Key.ToLower())))
            {
                updateBuilder.Column(item.Key, item.Value);
            }

            var where = GetSqlWhere(data.Where);
            if (data.Where.Exists(x => x.Symbol != "equal"))
            {
                foreach (var c in data.Where.Where(x => x.Symbol != "eqaul" && x.Parameters != null && x.Parameters.Count > 0))
                {
                    throw new Exception(string.Format("更新条件中的{0}未实现参数化!", c.Symbol));
                }

                updateBuilder.Where(where);
            }
            else
            {
                foreach (var c in data.Where)
                {
                    updateBuilder.Where(c.Column, c.Values[0]);
                }
            }

            return(updateBuilder);
        }
コード例 #3
0
        protected IUpdateBuilder BuilderParse(ParamUpdate param)
        {
            var data          = param.GetData();
            var updateBuilder = db.Update(data.Update.Length == 0 ? typeof(T).Name : data.Update);

            var dict = GetPersonDateForUpdate();

            foreach (var column in data.Columns.Where(column => !dict.ContainsKey(column.Key)))
            {
                updateBuilder.Column(column.Key, column.Value);
            }

            var properties = Zephyr.Utils.ZReflection.GetProperties(typeof(T));

            foreach (var item in dict.Where(item => properties.ContainsKey(item.Key.ToLower())))
            {
                updateBuilder.Column(item.Key, item.Value);
            }

            updateBuilder.Where(data.WhereSql);

            return(updateBuilder);
        }