Our next beta will have, among other things, paging built right into the EntitySpaces architecture. The EntitySpaces dynamic query API has two new properties, StartRow and PageSize. Here is a very simple dynamic query that uses these two new properties. This feature will be built into all providers for databases that support some sort of built in paging. The example below uses the EntitySpaces.SqlClientProvider and only works on SQL 2005 as it takes advantage of the new ROW_NUMBER() function in SQL 2005.
EmployeesCollection coll = new EmployeesCollection();
coll.Query.Select(coll.Query.LastName, coll.Query.FirstName);
coll.Query.OrderBy(coll.Query.LastName, esOrderByDirection.Ascending);
coll.Query.es.StartRow = 25;
coll.Query.es.PageSize = 10;
if(coll.Query.Load())
{
Console.WriteLine(coll.Query.es.LastQuery);
}
Notice that we print the Query's LastQuery property. EntitySpaces always provides the raw text back from a query for debugging purposes. Let's take a look at the SQL generated and executed by EntitySpaces.
WITH [withStatement] AS
(
SELECT [LastName],[FirstName] , ROW_NUMBER() OVER( ORDER BY [LastName] ASC) AS ESRN FROM [Northwind].[dbo].[Employees]
)
SELECT [LastName],[FirstName] FROM [withStatement] WHERE ESRN BETWEEN 25 AND 34
Now that we have paging built into the EntitySpaces architecture our new esDataSource control for ASP.NET will expose a PageSize property that you can set. The esDataSource control will then perform all of the paging logic for you automatically. You will be able to build sortable pages that can add, edit, and delete and page through data in a matter of minutes.
The EntitySpaces Team
--
EntitySpaces LLC
Persistence Layer and Business Objects for Microsoft .NET
http://www.entityspaces.net/