public CDataAccessBase[] getObjList(IDataAccessBase obj, int RecordCount) { CClassQuery ccq = obj.generateListSql(RecordCount); if (ccq == null) { return(null); } Type t = obj.GetType(); DataTable dt = this.ExecQuery(ccq.sql, ccq.parameters); CDataAccessBase[] ba = null; if (dt.Rows.Count > 0) { ba = new CDataAccessBase[dt.Rows.Count]; } int i = 0; foreach (DataRow dr in dt.Rows) { CDataAccessBase k = (CDataAccessBase)Activator.CreateInstance(t); k.InitFromDataRow(dr); ba[i] = k; i++; } return(ba); }
public CDataAccessBase[] getObjList(IDataAccessBase obj, int PageIndex, int PageSize) { Type t = obj.GetType(); DataTable dt = ExecProcedure("AllowPaging", new[] { new OleDbParameter("@pageindex", PageIndex), new OleDbParameter("@PageSize", PageSize), new OleDbParameter("@tsql", obj.generateListSql()) } ).Tables[0]; CDataAccessBase[] ba = null; if (dt.Rows.Count > 0) { ba = new CDataAccessBase[dt.Rows.Count]; } int i = 0; foreach (DataRow dr in dt.Rows) { var k = (CDataAccessBase)Activator.CreateInstance(t); k.InitFromDataRow(dr); ba[i] = k; i++; } return(ba); }