private SourceList <T> GetList <T>(DbCommand cmd, DbTrans dbTran) where T : Entity { try { using (ISourceReader reader = dbProvider.ExecuteReader(cmd, dbTran)) { SourceList <T> list = new SourceList <T>(); FastCreateInstanceHandler creator = DataUtils.GetFastInstanceCreator(typeof(T)); while (reader.Read()) { T entity = (T)creator(); entity.SetAllValues(reader); entity.Attach(); list.Add(entity); } reader.Close(); return(list); } } catch { throw; } }
private ArrayList <TResult> GetListResult <TResult>(DbCommand cmd, DbTrans dbTran) { try { using (ISourceReader reader = dbProvider.ExecuteReader(cmd, dbTran)) { ArrayList <TResult> list = new ArrayList <TResult>(); if (typeof(TResult) == typeof(object[])) { while (reader.Read()) { List <object> objs = new List <object>(); for (int row = 0; row < reader.FieldCount; row++) { objs.Add(reader.GetValue(row)); } TResult result = (TResult)(objs.ToArray() as object); list.Add(result); } } else { while (reader.Read()) { list.Add(reader.GetValue <TResult>(0)); } } reader.Close(); return(list); } } catch { throw; } }