zoukankan      html  css  js  c++  java
  • 获取Model的所有属性字符串

       /// <summary>
            /// 返回属性字段,作用是Sql查询的时候用来替换 * , *查询会影响运行速度
           /// </summary>
           /// <typeparam name="T"></typeparam>
           /// <returns></returns>
            public string GetModelSqlstr<T>()
            {
                string RtnStr = string.Empty;
                try
                {
    
                    Type entityType = typeof(T); 
                    System.Reflection.PropertyInfo[] properties = entityType.GetProperties(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public);
    
                    foreach (PropertyInfo item in properties)
                    {
                        RtnStr = string.Format("{0},{1}", RtnStr, item.Name);
                    }
                    RtnStr = " "+RtnStr.TrimEnd(',').TrimStart(',')+" ";
                }
                catch (Exception)
                {
    
                    throw;
                }
    
                return RtnStr;
            }

       /// <summary>        /// 返回属性字段,作用是Sql查询的时候用来替换 * , *查询会影响运行速度       /// </summary>       /// <typeparam name="T"></typeparam>       /// <returns></returns>        public string GetModelSqlstr<T>()        {            string RtnStr = string.Empty;            try            {
                    Type entityType = typeof(T);                 System.Reflection.PropertyInfo[] properties = entityType.GetProperties(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public);
                    foreach (PropertyInfo item in properties)                {                    RtnStr = string.Format("{0},{1}", RtnStr, item.Name);                }                RtnStr = " "+RtnStr.TrimEnd(',').TrimStart(',')+" ";            }            catch (Exception)            {
                    throw;            }
                return RtnStr;        }

  • 相关阅读:
    SVN添加自动忽略文件.settings .project .classpath target等
    Ueditor富文本编辑器
    服务器搭建及使用
    Java各种对象(PO,BO,VO,DTO,POJO,DAO,Entity,JavaBean,JavaBeans)的区分
    Oracle 查询交集、并集、差集
    Oracle sql优化工具
    移动端click时间延迟300
    腾讯地图位置展示组件用法
    百度地图 卫星 二维
    $.load()的用法
  • 原文地址:https://www.cnblogs.com/lhlong/p/11058627.html
Copyright © 2011-2022 走看看