ISqlBuilderLoader.LoadByPage(int currentIndex, int pageSize, params object[] parameters) Method
.NET Standard 2.x
Retrieves data starting from a specified row by the built SQL statement.
Namespace: SnapObjects.Data
Assembly: SnapObjects.Data.dll
Syntax
public ILoadable<TModel> LoadByPage(int currentIndex, int pageSize, params object[] parameters);
Parameters
currentIndex
System.Int32
The zero-based index of the first record in the page.
pageSize
System.Int32
The count of rows in each page.
parameters
System.Object[]
(Optional) One or more values that you want to use as retrieval arguments in the SQL SELECT statement.
Returns
SnapObjects.Data.ILoadable<TModel>
Returns the ILoadable<TModel>
interface whose methods can be used to further obtain the result set, or perform data operations such as embedded queries.
Examples
The following code example demonstrates how to use the LoadByPage
method.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Appeon.ApiDoc.Models.School;
using SnapObjects.Data;
namespace Appeon.ApiDoc.ISqlBuilderLoaderExamples
{
public class LoadByPageExample
{
private readonly SchoolContext _context;
private ISqlModelMapper mapper;
public LoadByPageExample(SchoolContext dataContext)
{
// Sets the data context.
_context = dataContext;
mapper = _context.SqlModelMapper;
}
public void Example()
{
var builder = mapper.GetQueryBuilder<Person>();
int count = builder.LoadByPage(0, 30).ToList().Count;
Console.WriteLine("Count: {0}", count);
/*The code produces the following output:
Count: 30
*/
}
}
}
Applies to
.NET Standard
2.x