Gemstone Data Library
Show/Hide TOC

# TableOperations T QueryRecordsAsync(String, Boolean, Int32, Int32, CancellationToken, IRecordFilter) Method

Queries database and returns modeled table records for the specified sorting, paging and search parameters. Search executed against fields modeled with SearchableAttribute.

## Definition

Namespace: Gemstone.Data.Model
Assembly: Gemstone.Data (in Gemstone.Data.dll) Version: 1.0.159 -- Release Build+9666939f99852a601f77d33e6f63320df255766c
C#
View Source Request Example

    public IAsyncEnumerable<T> QueryRecordsAsync(
    	string? sortField,
    	bool ascending,
    	int page,
    	int pageSize,
    	CancellationToken cancellationToken,
    	params IRecordFilter?[]? recordFilters
    )

VB
View Source Request Example

    Public Function QueryRecordsAsync (
    	sortField As String,
    	ascending As Boolean,
    	page As Integer,
    	pageSize As Integer,
    	cancellationToken As CancellationToken,
    	ParamArray recordFilters As IRecordFilter()
    ) As IAsyncEnumerable(Of T)

C++
View Source Request Example

    public:
    IAsyncEnumerable<T>^ QueryRecordsAsync(
    	String^ sortField,
    	bool ascending,
    	int page,
    	int pageSize,
    	CancellationToken cancellationToken,
    	... array<IRecordFilter^>^ recordFilters
    )

JavaScript
View Source Request Example

    function QueryRecordsAsync(sortField, ascending, page, pageSize, cancellationToken, ... recordFilters);

#### Parameters

sortField String
  Field name to order-by.
ascending Boolean
  Sort ascending flag; set to false for descending.
page Int32
  Page number of records to return (1-based).
pageSize Int32
  Current page size.
cancellationToken CancellationToken
  Propagates notification that operations should be canceled.
recordFilters IRecordFilter
  Record Filters to be applied.

#### Return Value

IAsyncEnumerable T
An enumerable of modeled table row instances for queried records.

## Remarks

This function is used for record paging. Primary keys are cached server-side, typically per user session, to maintain desired per-page sort order. Call ClearPrimaryKeyCache to manually clear cache when table contents are known to have changed.

If the specified sortField has been marked with EncryptDataAttribute, establishing the primary key cache operation will take longer to execute since query data will need to be downloaded locally and decrypted so the proper sort order can be determined.

This is a convenience call to QueryRecords(String, Boolean, Int32, Int32, RecordRestriction) where restriction is generated by GetSearchRestrictions(IRecordFilter) using recordFilters.

## See Also

#### Reference

TableOperationsT Class
QueryRecordsAsync Overload
Gemstone.Data.Model Namespace