You are currently browsing legacy 3.5 version of documentation. Click here to switch to the newest 5.1 version.

We can help you with migration to the latest RavenDB

Contact Us Now
see on GitHub

Commands: StreamQueryAsync

StreamQueryAsync is used to Stream the query results to the client.

Syntax

Task<IAsyncEnumerator<FileHeader>> StreamQueryAsync(string query, string[] sortFields = null, int start = 0, int pageSize = int.MaxValue);
Parameters
query string The Lucene query
sortFields string[] The fields to sort by
start int The number of files that should be skipped
pageSize int The maximum number of file headers that will be retrieved

Return Value
Task<IAsyncEnumerator<FileHeader>> A task that represents the asynchronous operation. The task result is the enumerator of FileHeaders objects.

Example

using (var reader = await store.AsyncFilesCommands.StreamQueryAsync("Number:2", start: 10, pageSize: 20))
{
    while (await reader.MoveNextAsync())
    {
        allFilesMatchingCriteria.Add(reader.Current);
    }
}

By using the following code StreamQueryAsync can sort the result for the query:

var allFilesMatchingCriteria = new List<FileHeader>();
using (var reader = await store.AsyncFilesCommands.StreamQueryAsync("", sortFields: new string[] { "-__key" }))
{  
    while (await reader.MoveNextAsync())
    {
        allFilesMatchingCriteria.Add(reader.Current);
    }
}