Commands: Querying: How to query a database?
Use Query method to fetch results of a selected index according to a specified query.
string includes = null,
bool metadataOnly = false,
bool indexEntriesOnly = false);
||A name of an index to query
||A query definition containing all information required to query a specified index.
||An array of relative paths that specify related documents ids which should be included in a query result.
||True if returned documents should include only metadata without a document body.
||True if query results should contain only index entries.
||Object which represents results of a specified query.
A sample Query method call that returns orders for a company specified:
result = store.DatabaseCommands.Query("Orders/Totals", new IndexQuery
Query = "Company:companies/1"
List<RavenJObject> users = result.Results; // documents resulting from this query - orders
If a model of your documents is such that they reference others and you want to retrieve them together in a single query request, then you need to specify paths to properties that contain IDs of referenced documents:
result = store.DatabaseCommands.Query("Orders/Totals", new IndexQuery(),
List<RavenJObject> referencedDocs = result.Includes; // included documents - companies and employees