IDataStoreBase.RetrieveByPage(int currentIndex, int pageSize, params object[] arguments) Method
.NET Standard 2.x
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 int RetrieveByPage(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
System.Int32
Returns the number of rows retrieved (that is, rows in the primary buffer) if it succeeds, otherwise 0.
This method always returns -1 if the data source is external. Use a method such as ImportJson
to populate the DataStore.
Examples
The following code example demonstrates how to retrieve rows by page from the database for DataStore.
using DWNet.Data;
using System;
namespace Appeon.ApiDoc.IDataStoreBaseExamples
{
public class RetrieveByPageExample
{
private readonly SchoolContext _context;
public RetrieveByPageExample(SchoolContext dataContext)
{
// Sets the data context
_context = dataContext;
}
public void Example()
{
// Instantiates a DataStore object with datawindow: d_department.
var datastore = new DataStore("d_department", _context);
// Gets two rows of data starting from the first row
datastore.RetrieveByPage(1, 2);
Console.WriteLine("Rowcount: {0}", datastore.RowCount);
// 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);
/*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