IDataStoreBase.RetrieveByPageAsync(int currentIndex, int pageSize, params object[] arguments) Method
.NET Standard 2.x
Asynchronously retrieves a number of rows in the database starting from the specified row. If arguments are included, the argument values are used for the retrieval arguments in the SQL SELECT statement for the DataStore.
Namespace: DWNet.Data
Assembly: DWNet.Data.dll
Syntax
public Task<int> RetrieveByPageAsync(int currentIndex, int pageSize, params object[] arguments)
Pararmeters
currentIndex
System.Int32
The index number of the current row in the DataStore.
pageSize
System.Int322
Number of rows to be retrieved.
arguments
System.Object[]
(Optional) One or more values that you want to use as retrieval arguments in the SQL SELECT statement defined in the DataStore.
Returns
Task<int>
Returns a task that represents the asynchronous operation.
Examples
The following code example demonstrates how to retrieve rows by page asynchronously from the database for DataStore
.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using DWNet.Data;
namespace Appeon.ApiDoc.IDataStoreBaseExamples
{
public class RetrieveByPageAsyncExample
{
private readonly SchoolContext _context;
public RetrieveByPageAsyncExample(SchoolContext dataContext)
{
// Sets the data context
_context = dataContext;
}
public async Task<int> Example1()
{
// Instantiates a DataStore object with datawindow: d_department.
var datastore = new DataStore("d_department", _context);
try
{
// Gets two rows of data starting from the first row
int task = await datastore.RetrieveByPageAsync(1, 2, new object[] { 1 });
Console.WriteLine("Rowcount: {0}", datastore.RowCount);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
// Sets DataWindow parameters
datastore.DwMeta.DataWindow.Table.AddArgument("DepartmentID", typeof(int));
string sql = datastore.GetSqlSelect();
sql += " where DepartmentID > :DepartmentID";
datastore.SetSqlSelect(sql, false);
// Gets the row whose DepartmentID = 2
datastore.RetrieveByPage(1, 2, 2);
Console.WriteLine("Rowcount: {0}", datastore.RowCount);
return datastore.RowCount;
/*This code produces the following output:
Rowcount: 2
Rowcount: 1
*/
}
}
}
Example Refer To
Model Class: D_Department
DataWindow File: d_department
Applies to
.NET Standard
2.x