You are currently browsing legacy 3.0 version of documentation. Click here to switch to the newest 4.2 version.

We can help you with migration to the latest RavenDB

Contact Us Now
see on GitHub

Commands: Querying: How to stream query results?

Use StreamQuery method to stream results of a selected index according to a specified query.

Syntax

IEnumerator<RavenJObject> StreamQuery(
	string index,
	IndexQuery query,
	out QueryHeaderInformation queryHeaderInfo);

Parameters
index string A name of an index to query
query IndexQuery A query definition containing all information required to query a specified index.
queryHeaderInfo QueryHeaderInformation Information about performed query
Return Value
IEnumerator<RavenJObject> Enumerator with query results
QueryHeaderInformation Information about performed query

Example

QueryHeaderInformation queryHeaderInfo;
IEnumerator<RavenJObject> enumerator = store
	.DatabaseCommands
	.StreamQuery(
		"Orders/Totals",
		new IndexQuery
		{
			Query = "Company:companies/1"
		},
		out queryHeaderInfo);

while (enumerator.MoveNext())
{
	RavenJObject order = enumerator.Current;
}