Get all the properties of the string Model

 

 

   ///  <Summary> 
        /// Returns a property field, the time function is used to replace * Sql query, the query will affect the speed *
        ///  </ Summary> 
       ///  <typeParam name = "T"> </ typeParam> 
       ///  <Returns> </ Returns> 
        public  String GetModelSqlstr <T> () 
        { 
            String RtnStr = String .Empty;
             the try 
            { 

                the 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> /// Returns a property field, the time function is used to replace * Sql query, the query will affect the speed * /// </ summary> /// <typeparam name = "T"> </ typeParam> /// <Returns> </ Returns> public String GetModelSqlstr <T> () {String RtnStr = string.Empty; the try {
                the Type entityType = typeof (T); System.Reflection.PropertyInfo [] = entityType.GetProperties Properties (System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public);
                the foreach (PropertyInfo in Item Properties) = {RtnStr string.Format ( "{0}, {}. 1", RtnStr, item.name);} RtnStr = "" + RtnStr.TrimEnd ( ' ,') TrimStart ( ',') +. "";            }            catch (Exception)            {
                throw;            }
            return RtnStr;        }

Guess you like

Origin www.cnblogs.com/lhlong/p/11058627.html