/// <summary> /// 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. /// </summary> /// <remarks> /// This call replaces any previously specified end position in the query. /// </remarks> /// <param name="fieldValues">The field values. Must not be null or empty, or have more values than query has orderings.</param> /// <returns>A new query based on the current one, but with the specified end position.</returns> public Query EndAt(params object[] fieldValues) { var query = QueryProto.Clone(); query.EndAt = CreateCursor(fieldValues, false); return(WithQuery(query)); }
/// <summary> /// 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. /// </summary> /// <remarks> /// This call replaces any previously specified start position in the query. /// </remarks> /// <param name="fieldValues">The field values. Must not be null or empty, or have more values than query has orderings.</param> /// <returns>A new query based on the current one, but with the specified start position.</returns> public Query StartAt(params object[] fieldValues) { var query = QueryProto.Clone(); query.StartAt = CreateCursor(fieldValues, true); return(WithQuery(query)); }
/// <summary> /// Specifies a number of results to skip. /// </summary> /// <remarks> /// This call replaces any previously-specified offset in the query. /// </remarks> /// <param name="offset">The number of results to skip. Must be greater than or equal to 0.</param> /// <returns>A new query based on the current one, but with the specified offset applied.</returns> public Query Offset(int offset) { GaxPreconditions.CheckArgumentRange(offset, nameof(offset), 0, int.MaxValue); var query = QueryProto.Clone(); query.Offset = offset; return(WithQuery(query)); }
/// <summary> /// Specifies the maximum number of results to return. /// </summary> /// <remarks> /// This call replaces any previously-specified limit in the query. /// </remarks> /// <param name="limit">The maximum number of results to return. Must be greater than or equal to 0.</param> /// <returns>A new query based on the current one, but with the specified limit applied.</returns> public Query Limit(int limit) { GaxPreconditions.CheckArgumentRange(limit, nameof(limit), 0, int.MaxValue); var query = QueryProto.Clone(); query.Limit = limit; return(WithQuery(query)); }
private Query OrderBy(FieldPath fieldPath, Direction direction) { GaxPreconditions.CheckState(QueryProto.StartAt == null && QueryProto.EndAt == null, "All orderings must be specified before StartAt, StartAfter, EndBefore or EndAt are called."); var query = QueryProto.Clone(); query.OrderBy.Add(new Order { Field = fieldPath.ToFieldReference(), Direction = direction }); return(WithQuery(query)); }
/// <summary> /// Specifies the field paths to return in the results. /// </summary> /// <remarks> /// This call replaces any previously-specified projections in the query. /// </remarks> /// <param name="fieldPaths">The field paths to select. Must not be null or empty, or contain null elements.</param> /// <returns>A new query based on the current one, but with the specified projection applied.</returns> public Query Select(params FieldPath[] fieldPaths) { GaxPreconditions.CheckNotNull(fieldPaths, nameof(fieldPaths)); GaxPreconditions.CheckArgument(fieldPaths.Length != 0, nameof(fieldPaths), "Projection must specify at least one field"); GaxPreconditions.CheckArgument(!fieldPaths.Contains(null), nameof(fieldPaths), "Field paths must not contain a null element"); var query = QueryProto.Clone(); query.Select = new Projection { Fields = { fieldPaths.Select(fp => fp.ToFieldReference()) } }; return(WithQuery(query)); }
private Query WithFilter(Filter filter) { var query = QueryProto.Clone(); if (query.Where == null) { query.Where = filter; } else if (query.Where.FilterTypeCase == Filter.FilterTypeOneofCase.CompositeFilter) { query.Where.CompositeFilter.Filters.Add(filter); } else { query.Where = new Filter { CompositeFilter = new CompositeFilter { Op = CompositeFilter.Types.Operator.And, Filters = { query.Where, filter } } }; } return(WithQuery(query)); }