예제 #1
0
        private string GenExpandoUpdateParaString(ExpandoObject obj)
        {
            var ret     = new StringBuilder();
            var i       = 1;
            var pg      = new Utility.ExpandoPorpertyGetter();
            var paraDic = pg.GetPropertyDic(obj);

            foreach (var key in paraDic.Keys)
            {
                ret.Append(" " + key + "=@" + key + " ");
                if (i < paraDic.Keys.Count)
                {
                    ret.Append(" , ");
                    i++;
                }
            }
            return(ret.ToString());
        }
예제 #2
0
        private void setProValueToDynPara(DynamicParameters dp, Object o)
        {
            Type type = o.GetType();

            if (type.Equals(typeof(ExpandoObject)))
            {
                var pg      = new Utility.ExpandoPorpertyGetter();
                var paraDic = pg.GetPropertyDic(o);
                foreach (var key in paraDic.Keys)
                {
                    dp.Add("@" + key, paraDic[key]);
                }
            }
            else
            {
                IList <PropertyInfo> props = new List <PropertyInfo>(type.GetProperties());
                foreach (PropertyInfo prop in props)
                {
                    object propValue = prop.GetValue(o, null);
                    dp.Add("@" + prop.Name, propValue);
                }
            }
        }