IDataStoreBase.Retrieve(params object[] arguments) Method
.NET Standard 2.x
Retrieves rows from the database. 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 Retrieve(params object[] arguments);
Pararmeters
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 and -1 if it fails.
This method always returns -1 if the data source is external. Use a method such as ImportJson to populate the DataStore.
Remarks
After rows are retrieved, the DataStore's filter is applied. Therefore, any retrieved rows that do not meet the filter criteria are immediately moved to the filter buffer and are not included in the return count.
Before you can retrieve rows for the DataStore, you must specify a DataContext object with the constructor of DataStore or SetDataContext method to establish a database connection.
Normally, when you call the Retrieve method, any rows that are already in the DataStore are discarded and replaced with the retrieved rows. You can set DwRetrieveEventArgs.IsResetBuffer to false in the RetrieveStart event to prevent this. In this case, Retrieve adds any retrieved rows to the ones that already exist in the buffers.
Events
The Retrieve method triggers these events: RetrieveStart and RetrieveEnd.
None of these events is triggered if the data source is external, because Retrieve always fails. You must use one of the import methods to populate the DataStore.
Examples
The following code example retrieves data from the database.
using DWNet.Data;
using System;
namespace Appeon.ApiDoc.IDataStoreBaseExamples
{
public class RetrieveExample
{
private readonly SchoolContext _context;
public RetrieveExample(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);
// Retrieves rows from the database for datastore
datastore.Retrieve();
Console.WriteLine("After Retrieve, Rowcount: {0}",
datastore.RowCount);
/*This code produces the following output:
After Retrieve, Rowcount: 4
*/
}
}
}
Example Refer To
Model Class: D_Department
DataWindow File: d_department
Applies to
.NET Standard
2.x