////// 返回属性字段,作用是Sql查询的时候用来替换 * , *查询会影响运行速度 /// ////// public string GetModelSqlstr () { 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; }