public PageResult <List <Te> > PageRequest(PageRequest <Tm> pageRequest) { var where = this.CombinWhere(pageRequest.AutoWhere(), pageRequest.ManualWhere()); int totalCount = this.Count(where); pageRequest.CheckPage(totalCount); var top = pageRequest.CurrentPage * pageRequest.PageSize; var indexFrom = top - pageRequest.PageSize + 1; var indexEnd = top; var orderBy = String.IsNullOrEmpty(pageRequest.OrderBy) ? TableMapper.DefaultOrderBy : pageRequest.OrderBy; var sql = string.Format("select {0} from (select top {1} ROW_NUMBER() over( order by {2}) as RowNumber, {3} from [{4}] {5}{6}) t where RowNumber between {7} and {8}", TableMapper.SelectMappingFileds, top, orderBy, TableMapper.SelectFileds, TableMapper.TableName, TableMapper.ShortTableName, where, indexFrom, indexEnd); var list = this.Querys <Te>(sql); return(new PageResult <List <Te> >(list, totalCount, pageRequest.PageSize, pageRequest.CurrentPage)); }