 SQL Server Paginazione Record Generica
Pubblicato il 23/04/2010
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[GetPagedRecords]
@TableName varchar(100),
@pageSize int,
@page int,
@filter varchar(max) = null,
@order varchar(100) = null
AS
BEGIN
declare @sql varchar(max)
select @sql = '
with paged as (
select row_number() over (order by ' +
case
when @order is null then '@@IDENTITY'
else @order
end +
') as ''RowNum'', *
from ' + @TableName +
case
when @filter is null then ''
else ' where ' + @filter
end +
')
select * from paged where (RowNum between ' +
Convert(varchar, (@page - 1) * @pageSize) + ' and ' +
Convert(varchar, (@page * @pageSize)) + ');'
exec(@sql)
END
A proposito dell'autore
Sviluppatore C#
Microsoft Certified Technology Specialist su WPF
Buona esperienza nello sviluppo di architetture enterprise modulari sfruttando le tecnologie WPF, WCF e Prism (CAG).
Buona conoscenza di Asp.net, Telerik RadControls, Java
Discreta conoscenza di Entity Framework, C/C++ ANSI e Win32, Html, Xhtml, Css, Javascript con jQuery, Silverlight, SQL Server
Basi di Telerik Sitefinity CMS, Jsp, Pascal, Python, Ruby, Ruby on Rails, Cobol 85, SharePoint 2007/2010
Cenni di Objective-C per lo sviluppo su Mac e iPhone/iPod Touch
OS: Linux (Gentoo, Slackware, Debian, Ubuntu), Windows XP/Seven/Server, Mac OS X
Tools: Visual Studio, Eclipse, Netbeans, Subversion, Team Foundation Server
Metodologie: Scrum, Extreme Programming
|
Aggiungi un commento