You are currently browsing legacy 3.0 version of documentation. Click here to switch to the newest 5.0 version.
Another great feature offered by the session is the querying support. The
Query method is an entry point to build a query that will be used to look for files on a file system according to the specified criteria.
Query method returns an object that allows you to construct a query by using available predicates and logical operators.
In order to get the results you need to materialize the query by using one of the following methods:
The querying API is the same as the rest of RavenFS client methods, which means it exposes only the asynchronous methods.
Default page size
The default value of a page size for a query is 1024 results. In order to retrieve a different number of results in a single query use the
If there are fewer than 1024 files in a file system, the below code will return all of them because the query does not contain any filtering condition. If there are more than 1024 files, it will return only the first 1024 results according to the default value of the
List<FileHeader> files = await session.Query().ToListAsync();
In this example we will get the first file that has less than 100 bytes or
null if no such file does not exist.
FileHeader file = await session .Query() .WhereLessThan(x => x.TotalSize, 100) .FirstOrDefaultAsync();