C#使用反射获取listT

C#使用反射获取listT

public List<T> GetListBySql<T>(string sql)
        {
            DataTable dt = GetDataTable(sql);

            if (dt == null || dt.Rows.Count == 0) return new List<T>();

            return GetEntityListByDatatable<T>(dt);
        }

  

 public List<T> GetListBySql<T>(string sql, MySqlParameter[] sqlparemeter)
        {
            DataTable dt = GetDataTable(sql, sqlparemeter);

            if (dt == null || dt.Rows.Count == 0) return new List<T>();

            return GetEntityListByDatatable<T>(dt);
        }

  

 List<T> list = new List<T>();

            HashSet<string> hashSetTableColumns = new HashSet<string>();
            foreach (DataColumn dtColumn in dataTable.Columns) hashSetTableColumns.Add(dtColumn.ColumnName);

            PropertyInfo[] piArr = ReflectionUtility.GetReflectionUtility.GetType<T>(FastObjectFactory.CreateObjectFactory<T>()).GetProperties();

  

 

性能非常优秀。

 

 

 

done

 

posted @ 2025-04-11 12:03  liskov_design  阅读(30)  评论(0)    收藏  举报