{
SetValue(propInfo, obj, columnValue);
}
}
T model = default(T);
model = obj as T;
listModels.Add(model);
}
}
finally
{
rdr.Close();
rdr.Dispose();
Monitor.Exit(objSync);
}
return listModels;
}
#endregion
#region query for dictionary
/// <summary>
/// 查询数据表项并转换为对应实体
/// </summary>
/// <typeparam name="K"></typeparam>
/// <typeparam name="T"></typeparam>
/// <param name="key">字典对应key列名</param>
/// <param name="objType"></param>
/// <param name="rdr"></param>
/// <returns></returns>
public static IDictionary<K, T> QueryForDictionary<K, T>(string key, string sqlStr, CommandType cmdType, List<DbParameter> listParams, Type objType, IDbOperation dbOperation)
where T : class, new()
{
IDataReader rdr = dbOperation.ExecuteReader(sqlStr, cmdType, listParams);
IDictionary<K, T> dictModels = new Dictionary<K, T>();
try
{
Monitor.Enter(objSync);
Hashtable ht = CreateHashColumnName(rdr);
while (rdr.Read())
{
Object obj = Activator.CreateInstance(objType);
PropertyInfo[] properties = objType.GetProperties();
object dictKey = null;
foreach (PropertyInfo propInfo in properties)
{
7/13 首页 上一页 5 6 7 8 9 10 下一页 尾页 |