/// <summary> /// 获取分页数据 /// </summary> /// <typeparam name="TEntity"></typeparam> /// <typeparam name="TQueryForm"></typeparam> /// <param name="mapper"></param> /// <param name="session"></param> /// <param name="command"></param> /// <param name="statementName"></param> /// <param name="form"></param> /// <param name="enableLog"></param> /// <returns></returns> public static List<TEntity> QueryForPaging<TEntity, TQueryForm>(ISqlMapper mapper, ISqlMapSession session, IDbCommand command, string statementName, TQueryForm form, bool enableLog = true) where TEntity : IEntity where TQueryForm : IQueryForm { IPagingSQL paging = PagingSQLFactory.Create(mapper.DataSource.DbProvider.Name); var sql = mapper.GetRuntimeSql(statementName, form, session); if (form.StartIndex > -1 && form.EndIndex > -1) { sql = paging.GetPagingSQL(sql, form.OrderByColumn, form.StartIndex.Value, form.EndIndex.Value, form.OrderBy); } sql = paging.BuildOrderBy(sql, form.OrderByColumn, form.OrderBy); command.CommandText = sql; string paramString = BuildParams(mapper, statementName, form, command); IDataAdapter dataAdapter = session.CreateDataAdapter(command); DataSet set = new DataSet(); dataAdapter.Fill(set); DataTable table = set.Tables[0]; var list = table.ToList<TEntity>().ToList(); if (enableLog) { SimpleLogger logger = new SimpleLogger(); logger.Write(sql, true); logger.Write(paramString, true); } return list; }