public PageResult <T> FindPage <T>(string strSQL, ParamMap param) where T : new() { PageResult <T> pageResult = new PageResult <T>(); List <T> list = new List <T>(); IDataReader sdr = null; IDbConnection connection = null; try { connection = GetConnection(); bool closeConnection = GetWillConnectionState(); strSQL = strSQL.ToLower(); String countSQL = SQLBuilderHelper.builderCountSQL(strSQL); String columns = SQLBuilderHelper.fetchColumns(strSQL); T entity = new T(); PropertyInfo[] properties = ReflectionHelper.GetProperties(entity.GetType()); TableInfo tableInfo = EntityHelper.GetTableInfo(entity, DbOperateType.SELECT, properties); if (param.IsPage && !SQLBuilderHelper.isPage(strSQL)) { strSQL = SQLBuilderHelper.builderPageSQL(strSQL, param.OrderFields, param.IsDesc); } if (AdoHelper.DbType == DatabaseType.ACCESS) { strSQL = SQLBuilderHelper.builderAccessSQL(strSQL, param.toDbParameters()); sdr = AdoHelper.ExecuteReader(closeConnection, connection, CommandType.Text, strSQL); } else { sdr = AdoHelper.ExecuteReader(closeConnection, connection, CommandType.Text, strSQL, param.toDbParameters()); } int count = this.Count(countSQL, param); list = EntityHelper.toList <T>(sdr, tableInfo, properties); pageResult.Total = count; pageResult.DataList = list; } catch (Exception ex) { throw ex; } finally { if (sdr != null) { sdr.Close(); } } return(pageResult); }