获取object值


方法

   /// 
        /// 获取 obj value
        /// 
        /// 对象
        /// 对象内字段
        /// 
        public static object GetDataValue( object info, string field)
        {
            try
            { 
                if (info == null) return null;
                Type t = info.GetType();
                IEnumerable property = from pi in t.GetProperties() where pi.Name.ToLower() == field.ToLower() select pi;
                return property.First().GetValue(info, null);

            }
            catch (Exception ex)
            {
                return null;
            }
        }

调用

object rsRes = null;
             
rsRes = conn.QueryBySQLPage<object>(qsql, page, size, orderby);
object TotalObj = MyAppApi.Comm.Commonly.GetDataValue(rsRes, "TotalNum");
C