コード例 #1
0
 /// <summary>
 /// 获取被修改的字段
 /// </summary>
 /// <returns></returns>
 public ParameCollection GetUpdateField(DBAdapter.DBAdapterBase dBAdapterBase = null, bool check = true)
 {
     var c = new ParameCollection();
     if (this.GetChanges().Count > 0)//按手动指定更改
     {
         var fields = TypeCache.GetProperties(GetType(), true);
         foreach (var item in this.GetChanges())
         {
             var key = item.Key.Replace("$", "");
             var f = fields[key];
             if (f == null)
                 continue;
             if (f.IsPrimaryKey)
                 continue;
             var value = item.Value;
             //如果表示值为被追加 名称为$name
             //使用Cumulation扩展方法后按此处理
             if (key != item.Key)//按$name=name+'123123'
             {
                 if (dBAdapterBase != null)
                 {
                     value = dBAdapterBase.GetFieldConcat(dBAdapterBase.KeyWordFormat(f.MapingName), value, f.PropertyType);
                 }
             }
             c[item.Key] = value;
         }
         return c;
     }
     return c;
 }
コード例 #2
0
        /// <summary>
        /// 获取被修改的字段
        /// </summary>
        /// <returns></returns>
        public ParameCollection GetUpdateField(DBAdapter.DBAdapterBase dBAdapterBase = null, bool check = true)
        {
            var c      = new ParameCollection();
            var fields = TypeCache.GetProperties(GetType(), true);

            if (this.GetChanges().Count > 0)//按手动指定更改
            {
                foreach (var item in this.GetChanges())
                {
                    var key = item.Key.Replace("$", "");
                    var f   = fields[key];
                    if (f == null)
                    {
                        continue;
                    }
                    if (f.IsPrimaryKey)
                    {
                        continue;
                    }
                    var value = item.Value;
                    //如果表示值为被追加 名称为$name
                    //使用Cumulation扩展方法后按此处理
                    if (key != item.Key)//按$name=name+'123123'
                    {
                        if (dBAdapterBase != null)
                        {
                            value = dBAdapterBase.GetFieldConcat(dBAdapterBase.KeyWordFormat(f.MapingName), value, f.PropertyType);
                        }
                    }
                    c[item.Key] = value;
                }
                return(c);
            }
            //按对象对比
            var origin = this.OriginClone;

            if (origin == null && check)
            {
                throw new CRLException("_originClone为空,请确认此对象是由查询创建");
            }
            foreach (var f in fields.Values)
            {
                if (f.IsPrimaryKey)
                {
                    continue;
                }
                var originValue  = f.GetValue(origin);
                var currentValue = f.GetValue(this);
                if (!Equals(originValue, currentValue))
                {
                    c.Add(f.MapingName, currentValue);
                }
            }
            return(c);
        }