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;        }

  • 相关阅读:
    IOS10.8.2安装
    如何读本地资源图片
    SqlServer2000日志文件过大问题处理
    xcode 4.5.1 免证书开发 破解
    C#生成注册码
    去掉Html标签方法
    数组处理
    返回代码
    Javascript图像处理——图像金字塔
    Javascript图像处理——图像形态学
  • 原文地址:https://www.cnblogs.com/lhlong/p/11058627.html
Copyright © 2011-2022 走看看