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

浙公网安备 33010602011771号