Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 47 additions & 12 deletions _posts/2009-04-03-paging.markdown
Original file line number Diff line number Diff line change
@@ -1,12 +1,47 @@
---
layout: post
title: "Paging"
---

# Paging

SubSonic supports server-side paging using Sql Server 2000, 2005, and MySQL. To use paging, simply make a call to the Paged method inline in the query:[Test] public void Exec_PagedSimple() { SubSonic.SqlQuery q = Select.AllColumnsFrom<Product>().Paged(1, 20) .Where("productid").IsLessThan(100); int records = q.GetRecordCount(); Assert.IsTrue(records

<h2> 20); } [Test] public void Exec_PagedJoined() { SubSonic.SqlQuery q = new Select("ProductId", "ProductName", "CategoryName") .From("Products").InnerJoin(Category.Schema).Paged(1, 20); int records = q.GetRecordCount(); Assert.IsTrue(records == 20); } [Test] public void Exec_PagedView() { SubSonic.SqlQuery q = new Select().From(Invoice.Schema).Paged(1, 20); int records = q.GetRecordCount(); Assert.IsTrue(records == 20); } [Test] public void Exec_PagedViewJoined() { SubSonic.SqlQuery q = new Select() .From(Invoice.Schema).Paged(1, 20).InnerJoin(Product.Schema); int records = q.GetRecordCount(); Assert.IsTrue(records </h2>

20); }
---
layout: post
title: "Paging"
---

# Paging #

SubSonic supports server-side paging using __Sql Server 2000, 2005, and MySQL__.

To use paging, simply make a call to the __Paged method__ inline in the query:

[Test]

public void Exec_PagedSimple()
{
SubSonic.SqlQuery q = Select.AllColumnsFrom<Product>().Paged(1, 20)
.Where("productid").IsLessThan(100);
int records = q.GetRecordCount(); Assert.IsTrue(records == 20);
}

[Test]

public void Exec_PagedJoined()
{
SubSonic.SqlQuery q = new Select("ProductId", "ProductName", "CategoryName")
.From("Products").InnerJoin(Category.Schema).Paged(1, 20);
int records = q.GetRecordCount();
Assert.IsTrue(records == 20);
}

[Test]

public void Exec_PagedView()
{
SubSonic.SqlQuery q = new Select().From(Invoice.Schema).Paged(1, 20);
int records = q.GetRecordCount();
Assert.IsTrue(records == 20);
}

[Test]

public void Exec_PagedViewJoined()
{
SubSonic.SqlQuery q = new Select().From(Invoice.Schema).Paged(1, 20).InnerJoin(Product.Schema);
int records = q.GetRecordCount();
Assert.IsTrue(records == 20);
}