反射的使用

View Code
        public string  SearchByEntity(Type t,string columnName)
        {
            //获取t的类型名
            string typeFullName = t.Name;
            //根据类型名获构造一个实体
            Type BaseType = Type.GetType("GWT.OnlineSys.LinqData." + typeFullName);
            //获取实体的指定的属性的值
            return Convert.ToString(BaseType.GetType().GetProperty(columnName).GetValue(BaseType, null));
        }

 

posted @ 2013-06-03 16:39  haiziguo  阅读(118)  评论(0编辑  收藏  举报