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

  • 相关阅读:
    yafu安装使用方法以及mismatched parens解决方法
    Bubble Babble Binary Data Encoding的简介以及bubblepy的安装使用方法
    python-gzip解压缩(实验吧SOS)
    python用模块zlib压缩与解压字符串和文件的方法
    IDA-IDC脚本编写语法
    南邮CTF密码学,mixed_base64
    各种类型文件头标准编码
    实验吧,心中无码
    Vue + webpack的纯前端项目如何配置外部配置文件
    js小技巧
  • 原文地址:https://www.cnblogs.com/lhlong/p/11058627.html
Copyright © 2011-2022 走看看