ISqlBuilderLoader.LoadByPageAsync(int currentIndex, int pageSize, params object[] parameters) Method
.NET Standard 2.x
Asynchronously retrieves data starting from a specified row by the built SQL statement.
Namespace: SnapObjects.Data
Assembly: SnapObjects.Data.dll
Syntax
public Task<ILoadable<TModel>> LoadByPageAsync(int currentIndex, int pageSize, params object[] parameters)
Parameters
currentIndex
System.Int32
The zero-based index number of the first row.
pageSize
System.Int32
The number of rows per page.
parameters
System.Object[]
(Optional) One or more values that you want to use as retrieval arguments in the SQL SELECT statement.
Returns
Task<ILoadable<TModel>>
Returns a task that represents the asynchronous operation.
Examples
The following code example demonstrates how to use the LoadByPageAsync
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 LoadByPageAsyncExample
{
private readonly SchoolContext _context;
private ISqlModelMapper mapper;
public LoadByPageAsyncExample(SchoolContext dataContext)
{
// Sets the data context.
_context = dataContext;
mapper = _context.SqlModelMapper;
}
public async Task<int> Example1()
{
var builder = mapper.GetQueryBuilder<Person>();
int count = (await builder.LoadByPageAsync(0, 30)).ToList().Count;
Console.WriteLine("Count: {0}", count);
return count;
/*The code produces the following output:
Count: 30
*/
}
}
}
Applies to
.NET Standard
2.x