public class Query : IEquatable<Query>
A query against a collection.
Implements
IEquatable<Query>Derived Types
Namespace
Google.Cloud.FirestoreAssembly
Google.Cloud.Firestore.dll
Remarks
CollectionReference derives from this class as a "return-all" query against the collection it refers to.
Properties
Database
public virtual FirestoreDb Database { get; }
The database this query will search over.
Property Value | |
---|---|
Type | Description |
FirestoreDb |
Methods
EndAt(DocumentSnapshot)
public Query EndAt(DocumentSnapshot snapshot)
Creates and returns a new query that ends at the document snapshot provided fields relative to the order of the query.
Parameter | |
---|---|
Name | Description |
snapshot | DocumentSnapshot The snapshot of the document to end at. |
Returns | |
---|---|
Type | Description |
Query | A new query based on the current one, but with the specified end position. |
This call replaces any previously specified end position in the query.
EndAt(Object[])
public Query EndAt(params object[] fieldValues)
Creates and returns a new query that ends at the provided fields relative to the order of the query. The order of the field values must match the order of the order-by clauses of the query.
Parameter | |
---|---|
Name | Description |
fieldValues | Object[] The field values. Must not be null or empty, or have more values than query has orderings. |
Returns | |
---|---|
Type | Description |
Query | A new query based on the current one, but with the specified end position. |
This call replaces any previously specified end position in the query.
EndBefore(DocumentSnapshot)
public Query EndBefore(DocumentSnapshot snapshot)
Creates and returns a new query that ends before the document snapshot provided fields relative to the order of the query.
Parameter | |
---|---|
Name | Description |
snapshot | DocumentSnapshot The snapshot of the document to end before. Must not be null. |
Returns | |
---|---|
Type | Description |
Query | A new query based on the current one, but with the specified end position. |
This call replaces any previously specified end position in the query.
EndBefore(Object[])
public Query EndBefore(params object[] fieldValues)
Creates and returns a new query that ends before the provided fields relative to the order of the query. The order of the field values must match the order of the order-by clauses of the query.
Parameter | |
---|---|
Name | Description |
fieldValues | Object[] The field values. Must not be null or empty, or have more values than query has orderings. |
Returns | |
---|---|
Type | Description |
Query | A new query based on the current one, but with the specified end position. |
This call replaces any previously specified end position in the query.
GetHashCode()
public override int GetHashCode()
Returns | |
---|---|
Type | Description |
Int32 |
GetSnapshotAsync(CancellationToken)
public Task<QuerySnapshot> GetSnapshotAsync(CancellationToken cancellationToken = default(CancellationToken))
Asynchronously takes a snapshot of all documents matching the query.
Parameter | |
---|---|
Name | Description |
cancellationToken | CancellationToken A cancellation token for the operation. |
Returns | |
---|---|
Type | Description |
Task<QuerySnapshot> | A snapshot of documents matching the query. |
Limit(Int32)
public Query Limit(int limit)
Specifies the maximum number of results to return.
Parameter | |
---|---|
Name | Description |
limit | Int32 The maximum number of results to return. Must be greater than or equal to 0. |
Returns | |
---|---|
Type | Description |
Query | A new query based on the current one, but with the specified limit applied. |
This call replaces any previously-specified limit in the query.
LimitToLast(Int32)
public Query LimitToLast(int limit)
Creates and returns a new query that only returns the last limit
matching documents.
Parameter | |
---|---|
Name | Description |
limit | Int32 The maximum number of results to return. Must be greater than or equal to 0. |
Returns | |
---|---|
Type | Description |
Query | A new query based on the current one, but with the specified limit applied. |
You must specify at least one OrderBy(String) clause for limit-to-last queries. Otherwise, an InvalidOperationException is thrown during execution.
Results for limit-to-last queries are only available once all documents are received, which means that these queries cannot be streamed using the StreamAsync(CancellationToken) method.
Listen(Action<QuerySnapshot>, CancellationToken)
public FirestoreChangeListener Listen(Action<QuerySnapshot> callback, CancellationToken cancellationToken = default(CancellationToken))
Listen to this query for changes. This method is a convenience method over Listen(Func<QuerySnapshot, CancellationToken, Task>, CancellationToken), wrapping a synchronous callback to create an asynchronous one.
Parameters | |
---|---|
Name | Description |
callback | Action<QuerySnapshot> The callback to invoke each time the query results change. Must not be null. |
cancellationToken | CancellationToken Optional cancellation token which may be used to cancel the listening operation. |
Returns | |
---|---|
Type | Description |
FirestoreChangeListener | A FirestoreChangeListener which may be used to monitor the listening operation and stop it gracefully. |
Listen(Func<QuerySnapshot, CancellationToken, Task>, CancellationToken)
public FirestoreChangeListener Listen(Func<QuerySnapshot, CancellationToken, Task> callback, CancellationToken cancellationToken = default(CancellationToken))
Listen to this query for changes.
Parameters | |
---|---|
Name | Description |
callback | Func<QuerySnapshot, CancellationToken, Task> The callback to invoke each time the query results change. Must not be null. |
cancellationToken | CancellationToken Optional cancellation token which may be used to cancel the listening operation. |
Returns | |
---|---|
Type | Description |
FirestoreChangeListener | A FirestoreChangeListener which may be used to monitor the listening operation and stop it gracefully. |
Offset(Int32)
public Query Offset(int offset)
Specifies a number of results to skip.
Parameter | |
---|---|
Name | Description |
offset | Int32 The number of results to skip. Must be greater than or equal to 0. |
Returns | |
---|---|
Type | Description |
Query | A new query based on the current one, but with the specified offset applied. |
This call replaces any previously-specified offset in the query.
OrderBy(FieldPath)
public Query OrderBy(FieldPath fieldPath)
Adds an additional ascending ordering by the specified path.
Parameter | |
---|---|
Name | Description |
fieldPath | FieldPath The field path to order by. Must not be null. |
Returns | |
---|---|
Type | Description |
Query | A new query based on the current one, but with the additional specified ordering applied. |
Unlike LINQ's OrderBy method, this call adds additional subordinate orderings to any
additionally specified. So query.OrderBy("foo").OrderBy("bar")
is similar
to a LINQ query.OrderBy(x => x.Foo).ThenBy(x => x.Bar)
.
This method cannot be called after a start/end cursor has been specified with StartAt(Object[]), StartAfter(Object[]), EndAt(Object[]) or EndBefore(Object[]).
OrderBy(String)
public Query OrderBy(string fieldPath)
Adds an additional ascending ordering by the specified path.
Parameter | |
---|---|
Name | Description |
fieldPath | String The dot-separated field path to order by. Must not be null or empty. |
Returns | |
---|---|
Type | Description |
Query | A new query based on the current one, but with the additional specified ordering applied. |
Unlike LINQ's OrderBy method, this call adds additional subordinate orderings to any
additionally specified. So query.OrderBy("foo").OrderBy("bar")
is similar
to a LINQ query.OrderBy(x => x.Foo).ThenBy(x => x.Bar)
.
This method cannot be called after a start/end cursor has been specified with StartAt(Object[]), StartAfter(Object[]), EndAt(Object[]) or EndBefore(Object[]).
OrderByDescending(FieldPath)
public Query OrderByDescending(FieldPath fieldPath)
Adds an additional descending ordering by the specified path.
Parameter | |
---|---|
Name | Description |
fieldPath | FieldPath The field path to order by. Must not be null. |
Returns | |
---|---|
Type | Description |
Query | A new query based on the current one, but with the additional specified ordering applied. |
Unlike LINQ's OrderBy method, this call adds additional subordinate orderings to any
additionally specified. So query.OrderBy("foo").OrderByDescending("bar")
is similar
to a LINQ query.OrderBy(x => x.Foo).ThenByDescending(x => x.Bar)
.
This method cannot be called after a start/end cursor has been specified with StartAt(Object[]), StartAfter(Object[]), EndAt(Object[]) or EndBefore(Object[]).
OrderByDescending(String)
public Query OrderByDescending(string fieldPath)
Adds an additional descending ordering by the specified path.
Parameter | |
---|---|
Name | Description |
fieldPath | String The dot-separated field path to order by. Must not be null or empty. |
Returns | |
---|---|
Type | Description |
Query | A new query based on the current one, but with the additional specified ordering applied. |
Unlike LINQ's OrderBy method, this call adds additional subordinate orderings to any
additionally specified. So query.OrderBy("foo").OrderByDescending("bar")
is similar
to a LINQ query.OrderBy(x => x.Foo).ThenByDescending(x => x.Bar)
.
This method cannot be called after a start/end cursor has been specified with StartAt(Object[]), StartAfter(Object[]), EndAt(Object[]) or EndBefore(Object[]).
Select(FieldPath[])
public Query Select(params FieldPath[] fieldPaths)
Specifies the field paths to return in the results.
Parameter | |
---|---|
Name | Description |
fieldPaths | FieldPath[] The field paths to select. Must not be null or contain null elements. If this is empty, the document ID is implicitly selected. |
Returns | |
---|---|
Type | Description |
Query | A new query based on the current one, but with the specified projection applied. |
This call replaces any previously-specified projections in the query.
Select(String[])
public Query Select(params string[] fieldPaths)
Specifies the field paths to return in the results.
Parameter | |
---|---|
Name | Description |
fieldPaths | String[] The dot-separated field paths to select. Must not be null or empty, or contain null or empty elements. |
Returns | |
---|---|
Type | Description |
Query | A new query based on the current one, but with the specified projection applied. |
This call replaces any previously-specified projections in the query.
StartAfter(DocumentSnapshot)
public Query StartAfter(DocumentSnapshot snapshot)
Creates and returns a new query that starts after the document snapshot provided fields relative to the order of the query.
Parameter | |
---|---|
Name | Description |
snapshot | DocumentSnapshot The snapshot of the document to start after. Must not be null. |
Returns | |
---|---|
Type | Description |
Query | A new query based on the current one, but with the specified start position. |
This call replaces any previously specified start position in the query.
StartAfter(Object[])
public Query StartAfter(params object[] fieldValues)
Creates and returns a new query that starts after the provided fields relative to the order of the query. The order of the field values must match the order of the order-by clauses of the query.
Parameter | |
---|---|
Name | Description |
fieldValues | Object[] The field values. Must not be null or empty, or have more values than query has orderings. |
Returns | |
---|---|
Type | Description |
Query | A new query based on the current one, but with the specified start position. |
This call replaces any previously specified start position in the query.
StartAt(DocumentSnapshot)
public Query StartAt(DocumentSnapshot snapshot)
Creates and returns a new query that starts at the document snapshot provided fields relative to the order of the query.
Parameter | |
---|---|
Name | Description |
snapshot | DocumentSnapshot The snapshot of the document to start at. Must not be null. |
Returns | |
---|---|
Type | Description |
Query | A new query based on the current one, but with the specified start position. |
This call replaces any previously specified start position in the query.
StartAt(Object[])
public Query StartAt(params object[] fieldValues)
Creates and returns a new query that starts at the provided fields relative to the order of the query. The order of the field values must match the order of the order-by clauses of the query.
Parameter | |
---|---|
Name | Description |
fieldValues | Object[] The field values. Must not be null or empty, or have more values than query has orderings. |
Returns | |
---|---|
Type | Description |
Query | A new query based on the current one, but with the specified start position. |
This call replaces any previously specified start position in the query.
StreamAsync(CancellationToken)
public IAsyncEnumerable<DocumentSnapshot> StreamAsync(CancellationToken cancellationToken = default(CancellationToken))
Returns an asynchronous sequence of snapshots matching the query.
Parameter | |
---|---|
Name | Description |
cancellationToken | CancellationToken The cancellation token to apply to the streaming operation. Note that even if this is None, a cancellation token can still be applied when iterating over the stream, by passing it into GetAsyncEnumerator(CancellationToken). If a cancellation token is passed both to this method and GetAsyncEnumerator, then cancelling either of the tokens will result in the operation being cancelled. |
Returns | |
---|---|
Type | Description |
IAsyncEnumerable<DocumentSnapshot> | An asynchronous sequence of document snapshots matching the query. |
Each time you iterate over the sequence, a new query will be performed.
WhereArrayContains(FieldPath, Object)
public Query WhereArrayContains(FieldPath fieldPath, object value)
Returns a query with a filter specifying that the value in fieldPath
must be an array containing
value
.
Parameters | |
---|---|
Name | Description |
fieldPath | FieldPath The field path to filter on. Must not be null. |
value | Object The value to check in the filter. |
Returns | |
---|---|
Type | Description |
Query | A new query based on the current one, but with the additional specified filter applied. |
This call adds additional filters to any previously-specified ones.
WhereArrayContains(String, Object)
public Query WhereArrayContains(string fieldPath, object value)
Returns a query with a filter specifying that the value in fieldPath
must be an array containing
value
.
Parameters | |
---|---|
Name | Description |
fieldPath | String The dot-separated field path to filter on. Must not be null or empty. |
value | Object The value to check in the filter. |
Returns | |
---|---|
Type | Description |
Query | A new query based on the current one, but with the additional specified filter applied. |
This call adds additional filters to any previously-specified ones.
WhereArrayContainsAny(FieldPath, IEnumerable)
public Query WhereArrayContainsAny(FieldPath fieldPath, IEnumerable values)
Returns a query with a filter specifying that fieldPath
must be
a field present in the document, with a value which is an array containing at least one value in values
.
Parameters | |
---|---|
Name | Description |
fieldPath | FieldPath The field path to filter on. Must not be null. |
values | IEnumerable The values to compare in the filter. Must not be null. |
Returns | |
---|---|
Type | Description |
Query | A new query based on the current one, but with the additional specified filter applied. |
This call adds additional filters to any previously-specified ones.
WhereArrayContainsAny(String, IEnumerable)
public Query WhereArrayContainsAny(string fieldPath, IEnumerable values)
Returns a query with a filter specifying that fieldPath
must be
a field present in the document, with a value which is an array containing at least one value in values
.
Parameters | |
---|---|
Name | Description |
fieldPath | String The dot-separated field path to filter on. Must not be null or empty. |
values | IEnumerable The values to compare in the filter. Must not be null. |
Returns | |
---|---|
Type | Description |
Query | A new query based on the current one, but with the additional specified filter applied. |
This call adds additional filters to any previously-specified ones.
WhereEqualTo(FieldPath, Object)
public Query WhereEqualTo(FieldPath fieldPath, object value)
Returns a query with a filter specifying that the value in fieldPath
must be
equal to value
.
Parameters | |
---|---|
Name | Description |
fieldPath | FieldPath The field path to filter on. Must not be null. |
value | Object The value to compare in the filter. |
Returns | |
---|---|
Type | Description |
Query | A new query based on the current one, but with the additional specified filter applied. |
This call adds additional filters to any previously-specified ones.
WhereEqualTo(String, Object)
public Query WhereEqualTo(string fieldPath, object value)
Returns a query with a filter specifying that the value in fieldPath
must be
equal to value
.
Parameters | |
---|---|
Name | Description |
fieldPath | String The dot-separated field path to filter on. Must not be null or empty. |
value | Object The value to compare in the filter. |
Returns | |
---|---|
Type | Description |
Query | A new query based on the current one, but with the additional specified filter applied. |
This call adds additional filters to any previously-specified ones.
WhereGreaterThan(FieldPath, Object)
public Query WhereGreaterThan(FieldPath fieldPath, object value)
Returns a query with a filter specifying that the value in fieldPath
must be greater than
value
.
Parameters | |
---|---|
Name | Description |
fieldPath | FieldPath The field path to filter on. Must not be null. |
value | Object The value to compare in the filter. |
Returns | |
---|---|
Type | Description |
Query | A new query based on the current one, but with the additional specified filter applied. |
This call adds additional filters to any previously-specified ones.
WhereGreaterThan(String, Object)
public Query WhereGreaterThan(string fieldPath, object value)
Returns a query with a filter specifying that the value in fieldPath
must be greater than
value
.
Parameters | |
---|---|
Name | Description |
fieldPath | String The dot-separated field path to filter on. Must not be null or empty. |
value | Object The value to compare in the filter. |
Returns | |
---|---|
Type | Description |
Query | A new query based on the current one, but with the additional specified filter applied. |
This call adds additional filters to any previously-specified ones.
WhereGreaterThanOrEqualTo(FieldPath, Object)
public Query WhereGreaterThanOrEqualTo(FieldPath fieldPath, object value)
Returns a query with a filter specifying that the value in fieldPath
must be greater than or
equal to value
.
Parameters | |
---|---|
Name | Description |
fieldPath | FieldPath The field path to filter on. Must not be null. |
value | Object The value to compare in the filter. |
Returns | |
---|---|
Type | Description |
Query | A new query based on the current one, but with the additional specified filter applied. |
This call adds additional filters to any previously-specified ones.
WhereGreaterThanOrEqualTo(String, Object)
public Query WhereGreaterThanOrEqualTo(string fieldPath, object value)
Returns a query with a filter specifying that the value in fieldPath
must be greater than or
equal to value
.
Parameters | |
---|---|
Name | Description |
fieldPath | String The dot-separated field path to filter on. Must not be null or empty. |
value | Object The value to compare in the filter. |
Returns | |
---|---|
Type | Description |
Query | A new query based on the current one, but with the additional specified filter applied. |
This call adds additional filters to any previously-specified ones.
WhereIn(FieldPath, IEnumerable)
public Query WhereIn(FieldPath fieldPath, IEnumerable values)
Returns a query with a filter specifying that fieldPath
must be
a field present in the document, with a value which is one of the values in values
.
Parameters | |
---|---|
Name | Description |
fieldPath | FieldPath The field path to filter on. Must not be null. |
values | IEnumerable The values to compare in the filter. Must not be null. |
Returns | |
---|---|
Type | Description |
Query | A new query based on the current one, but with the additional specified filter applied. |
This call adds additional filters to any previously-specified ones.
WhereIn(String, IEnumerable)
public Query WhereIn(string fieldPath, IEnumerable values)
Returns a query with a filter specifying that fieldPath
must be
a field present in the document, with a value which is one of the values in values
.
Parameters | |
---|---|
Name | Description |
fieldPath | String The dot-separated field path to filter on. Must not be null or empty. |
values | IEnumerable The values to compare in the filter. Must not be null. |
Returns | |
---|---|
Type | Description |
Query | A new query based on the current one, but with the additional specified filter applied. |
This call adds additional filters to any previously-specified ones.
WhereLessThan(FieldPath, Object)
public Query WhereLessThan(FieldPath fieldPath, object value)
Returns a query with a filter specifying that the value in fieldPath
must be less than
value
.
Parameters | |
---|---|
Name | Description |
fieldPath | FieldPath The field path to filter on. Must not be null. |
value | Object The value to compare in the filter. |
Returns | |
---|---|
Type | Description |
Query | A new query based on the current one, but with the additional specified filter applied. |
This call adds additional filters to any previously-specified ones.
WhereLessThan(String, Object)
public Query WhereLessThan(string fieldPath, object value)
Returns a query with a filter specifying that the value in fieldPath
must be less than
value
.
Parameters | |
---|---|
Name | Description |
fieldPath | String The dot-separated field path to filter on. Must not be null or empty. |
value | Object The value to compare in the filter. |
Returns | |
---|---|
Type | Description |
Query | A new query based on the current one, but with the additional specified filter applied. |
This call adds additional filters to any previously-specified ones.
WhereLessThanOrEqualTo(FieldPath, Object)
public Query WhereLessThanOrEqualTo(FieldPath fieldPath, object value)
Returns a query with a filter specifying that the value in fieldPath
must be less than or
equal to value
.
Parameters | |
---|---|
Name | Description |
fieldPath | FieldPath The field path to filter on. Must not be null. |
value | Object The value to compare in the filter. |
Returns | |
---|---|
Type | Description |
Query | A new query based on the current one, but with the additional specified filter applied. |
This call adds additional filters to any previously-specified ones.
WhereLessThanOrEqualTo(String, Object)
public Query WhereLessThanOrEqualTo(string fieldPath, object value)
Returns a query with a filter specifying that the value in fieldPath
must be less than or
equal to value
.
Parameters | |
---|---|
Name | Description |
fieldPath | String The dot-separated field path to filter on. Must not be null or empty. |
value | Object The value to compare in the filter. |
Returns | |
---|---|
Type | Description |
Query | A new query based on the current one, but with the additional specified filter applied. |
This call adds additional filters to any previously-specified ones.
WhereNotEqualTo(FieldPath, Object)
public Query WhereNotEqualTo(FieldPath fieldPath, object value)
Returns a query with a filter specifying that the value in fieldPath
must not be
equal to value
.
Parameters | |
---|---|
Name | Description |
fieldPath | FieldPath The field path to filter on. Must not be null. |
value | Object The value to compare in the filter. |
Returns | |
---|---|
Type | Description |
Query | A new query based on the current one, but with the additional specified filter applied. |
This call adds additional filters to any previously-specified ones.
WhereNotEqualTo(String, Object)
public Query WhereNotEqualTo(string fieldPath, object value)
Returns a query with a filter specifying that the value in fieldPath
must not be
equal to value
.
Parameters | |
---|---|
Name | Description |
fieldPath | String The dot-separated field path to filter on. Must not be null or empty. |
value | Object The value to compare in the filter. |
Returns | |
---|---|
Type | Description |
Query | A new query based on the current one, but with the additional specified filter applied. |
This call adds additional filters to any previously-specified ones.
WhereNotIn(FieldPath, IEnumerable)
public Query WhereNotIn(FieldPath fieldPath, IEnumerable values)
Returns a query with a filter specifying that fieldPath
must be
a field present in the document, with a value which is not one of the values in values
.
Parameters | |
---|---|
Name | Description |
fieldPath | FieldPath The field path to filter on. Must not be null. |
values | IEnumerable The values to compare in the filter. Must not be null. |
Returns | |
---|---|
Type | Description |
Query | A new query based on the current one, but with the additional specified filter applied. |
This call adds additional filters to any previously-specified ones.
WhereNotIn(String, IEnumerable)
public Query WhereNotIn(string fieldPath, IEnumerable values)
Returns a query with a filter specifying that fieldPath
must be
a field present in the document, with a value which is not one of the values in values
.
Parameters | |
---|---|
Name | Description |
fieldPath | String The dot-separated field path to filter on. Must not be null or empty. |
values | IEnumerable The values to compare in the filter. Must not be null. |
Returns | |
---|---|
Type | Description |
Query | A new query based on the current one, but with the additional specified filter applied. |
This call adds additional filters to any previously-specified ones.