C# Class Couchbase.N1QL.QueryRequest

Builds a N1QL query request.
Inheritance: IQueryRequest
Mostra file Open project: couchbase/couchbase-net-client Class Usage Examples

Public Properties

Property Type Description
ScanConsistencyResolver string>.Dictionary

Private Properties

Property Type Description
GetQueryParametersAsFormUrlencoded string
IQueryRequest bool

Public Methods

Method Description
AdHoc ( bool adHoc ) : IQueryRequest

If set to false, the client will try to perform optimizations transparently based on the server capabilities, like preparing the statement and then executing a query plan instead of the raw query.

The default is true; the query will executed in an ad-hoc manner, without special optomizations.

AddCredentials ( string username, string password, bool isAdmin ) : IQueryRequest

Adds a set of credentials to the list of credentials, in the form of user/password

Optional.

AddNamedParameter ( ) : IQueryRequest

Adds a collection of named parameters to the parameters to the statement or prepared statement.

Optional.

AddNamedParameter ( string name, object value ) : IQueryRequest

Adds a named parameter to the parameters to the statement or prepared statement.

Optional.

AddPositionalParameter ( ) : IQueryRequest

Adds a list of positional parameters to the statement or prepared statement.

AddPositionalParameter ( object value ) : IQueryRequest

Adds a positional parameter to the parameters to the statement or prepared statement.

Optional.

BaseUri ( Uri baseUri ) : IQueryRequest

Bases the URI.

ClientContextId ( string clientContextId ) : IQueryRequest

Clients the context identifier.

Compression ( Compression compression ) : IQueryRequest

Compression format to use for response data on the wire. Possible values are ZIP, RLE, LZMA, LZO, NONE.

Optional. The default is NONE.

ConsistentWith ( MutationState mutationState ) : IQueryRequest

Provides a means of ensuring "read your own writes" or RYOW consistency on the current query.

Note: ScanConsistency will be overwritten to N1QL.ScanConsistency.AtPlus.

Create ( ) : IQueryRequest

Creates a new QueryRequest object.

Create ( Couchbase.N1QL.QueryPlan plan, string originalStatement ) : IQueryRequest

Creates a query using the given plan as an optimization for the originalStatement.

Create ( string statement ) : IQueryRequest

Creates a new QueryRequest object with the specified statement.

Encoding ( Encoding encoding ) : IQueryRequest

Specifies the desired character encoding for the query results.

Optional.

Format ( System.Text.Format format ) : IQueryRequest

Desired format for the query results.

Optional.

GetBaseUri ( ) : Uri
GetFormValues ( ) : object>.IDictionary

Gets a IDictionary{K, V} of the name/value pairs to be POSTed to the service.

Since values will be POSTed as JSON, here we deal with unencoded typed values (like ints, Lists, etc...) rather than only strings.

GetFormValuesAsJson ( ) : string

Gets the JSON representation of this query for execution in a POST.

GetOriginalStatement ( ) : string

Gets the raw, unprepared N1QL statement.

If the statement has been optimized using Prepared, this will still return the original un-optimized statement.

GetPreparedPayload ( ) : Couchbase.N1QL.QueryPlan

Gets the prepared payload for this N1QL statement if IsPrepared() is true, null otherwise.

MaxServerParallelism ( int parallelism ) : IQueryRequest

Specifies the maximum parallelism for the query. A zero or negative value means the number of logical cpus will be used as the parallelism for the query. There is also a server wide max_parallelism parameter which defaults to 1. If a request includes max_parallelism, it will be capped by the server max_parallelism. If a request does not include max_parallelism, the server wide max_parallelism will be used.

Metrics ( bool includeMetrics ) : IQueryRequest

Specifies that metrics should be returned with query results.

Optional.

Prepared ( Couchbase.N1QL.QueryPlan preparedPlan, string originalStatement ) : IQueryRequest

Sets a N1QL statement to be executed in an optimized way using the given queryPlan.

Required if statement not provided, will erase a previously set Statement.

Pretty ( bool pretty ) : IQueryRequest

Pretty print the output.

True by default.

QueryRequest ( ) : System
QueryRequest ( Couchbase.N1QL.QueryPlan plan, string originalStatement ) : System
QueryRequest ( string statement ) : System
ReadOnly ( bool readOnly ) : IQueryRequest

If a GET request, this will always be true otherwise false.

Any value set here will be overridden by the type of request sent.

ScanConsistency ( ScanConsistency scanConsistency ) : IQueryRequest

Specifies the consistency guarantee/constraint for index scanning.

Optional.

ScanWait ( System.TimeSpan scanWait ) : IQueryRequest

Specifies the maximum time the client is willing to wait for an index to catch up to the vector timestamp in the request. If an index has to catch up, and the ScanWait time is exceed doing so, an error is returned.

Optional.

Signature ( bool includeSignature ) : IQueryRequest

Includes a header for the results schema in the response.

The default is true.

Statement ( string statement ) : IQueryRequest

Sets a N1QL statement to be executed.

Will erase a previous optimization of a statement using Prepared.

Timeout ( System.TimeSpan timeOut ) : IQueryRequest

Sets the maximum time to spend on the request.

Optional - the default is 0ms, which means the request runs for as long as it takes.

ToString ( ) : string

Returns a System.String that represents this instance.

UseStreaming ( bool streaming ) : IQueryRequest

Uses the streaming API for the returned results. This is useful for large result sets in that it limits the working size of the query and helps reduce the possibility of a OutOfMemoryException from occurring.

Private Methods

Method Description
GetQueryParametersAsFormUrlencoded ( ) : string
IQueryRequest ( ) : bool

#pragma warning disable 1584,1711,1572,1581,1580 True if the request exceeded it's ClientConfiguration.QueryRequestTimeout #pragma warning restore 1584,1711,1572,1581,1580

Method Details

AdHoc() public method

If set to false, the client will try to perform optimizations transparently based on the server capabilities, like preparing the statement and then executing a query plan instead of the raw query.
The default is true; the query will executed in an ad-hoc manner, without special optomizations.
public AdHoc ( bool adHoc ) : IQueryRequest
adHoc bool if set to false the query will be optimized if possible.
return IQueryRequest

AddCredentials() public method

Adds a set of credentials to the list of credentials, in the form of user/password
Optional.
username;cannot be null, empty or whitespace.
public AddCredentials ( string username, string password, bool isAdmin ) : IQueryRequest
username string The bucket or username.
password string The password of the bucket.
isAdmin bool True if connecting as an admin.
return IQueryRequest

AddNamedParameter() public method

Adds a collection of named parameters to the parameters to the statement or prepared statement.
Optional.
public AddNamedParameter ( ) : IQueryRequest
return IQueryRequest

AddNamedParameter() public method

Adds a named parameter to the parameters to the statement or prepared statement.
Optional.
public AddNamedParameter ( string name, object value ) : IQueryRequest
name string The name of the parameter.
value object The value of the parameter.
return IQueryRequest

AddPositionalParameter() public method

Adds a list of positional parameters to the statement or prepared statement.
public AddPositionalParameter ( ) : IQueryRequest
return IQueryRequest

AddPositionalParameter() public method

Adds a positional parameter to the parameters to the statement or prepared statement.
Optional.
public AddPositionalParameter ( object value ) : IQueryRequest
value object The value of the positional parameter.
return IQueryRequest

BaseUri() public method

Bases the URI.
public BaseUri ( Uri baseUri ) : IQueryRequest
baseUri System.Uri The base URI.
return IQueryRequest

ClientContextId() public method

Clients the context identifier.
public ClientContextId ( string clientContextId ) : IQueryRequest
clientContextId string The client context identifier.
return IQueryRequest

Compression() public method

Compression format to use for response data on the wire. Possible values are ZIP, RLE, LZMA, LZO, NONE.
Optional. The default is NONE.
public Compression ( Compression compression ) : IQueryRequest
compression Compression
return IQueryRequest

ConsistentWith() public method

Provides a means of ensuring "read your own writes" or RYOW consistency on the current query.
Note: ScanConsistency will be overwritten to N1QL.ScanConsistency.AtPlus.
public ConsistentWith ( MutationState mutationState ) : IQueryRequest
mutationState MutationState State of the mutation.
return IQueryRequest

Create() public static method

Creates a new QueryRequest object.
public static Create ( ) : IQueryRequest
return IQueryRequest

Create() public static method

Creates a query using the given plan as an optimization for the originalStatement.
public static Create ( Couchbase.N1QL.QueryPlan plan, string originalStatement ) : IQueryRequest
plan Couchbase.N1QL.QueryPlan The plan.
originalStatement string The original statement, unoptimized.
return IQueryRequest

Create() public static method

Creates a new QueryRequest object with the specified statement.
public static Create ( string statement ) : IQueryRequest
statement string The statement.
return IQueryRequest

Encoding() public method

Specifies the desired character encoding for the query results.
Optional.
public Encoding ( Encoding encoding ) : IQueryRequest
encoding System.Text.Encoding An enum.
return IQueryRequest

Format() public method

Desired format for the query results.
Optional.
public Format ( System.Text.Format format ) : IQueryRequest
format System.Text.Format An enum.
return IQueryRequest

GetBaseUri() public method

public GetBaseUri ( ) : Uri
return System.Uri

GetFormValues() public method

Gets a IDictionary{K, V} of the name/value pairs to be POSTed to the service.
Since values will be POSTed as JSON, here we deal with unencoded typed values (like ints, Lists, etc...) rather than only strings.
A statement or prepared plan must be provided.
public GetFormValues ( ) : object>.IDictionary
return object>.IDictionary

GetFormValuesAsJson() public method

Gets the JSON representation of this query for execution in a POST.
public GetFormValuesAsJson ( ) : string
return string

GetOriginalStatement() public method

Gets the raw, unprepared N1QL statement.
If the statement has been optimized using Prepared, this will still return the original un-optimized statement.
public GetOriginalStatement ( ) : string
return string

GetPreparedPayload() public method

Gets the prepared payload for this N1QL statement if IsPrepared() is true, null otherwise.
public GetPreparedPayload ( ) : Couchbase.N1QL.QueryPlan
return Couchbase.N1QL.QueryPlan

MaxServerParallelism() public method

Specifies the maximum parallelism for the query. A zero or negative value means the number of logical cpus will be used as the parallelism for the query. There is also a server wide max_parallelism parameter which defaults to 1. If a request includes max_parallelism, it will be capped by the server max_parallelism. If a request does not include max_parallelism, the server wide max_parallelism will be used.
public MaxServerParallelism ( int parallelism ) : IQueryRequest
parallelism int
return IQueryRequest

Metrics() public method

Specifies that metrics should be returned with query results.
Optional.
public Metrics ( bool includeMetrics ) : IQueryRequest
includeMetrics bool True to return query metrics.
return IQueryRequest

Prepared() public method

Sets a N1QL statement to be executed in an optimized way using the given queryPlan.
Required if statement not provided, will erase a previously set Statement.
is .
public Prepared ( Couchbase.N1QL.QueryPlan preparedPlan, string originalStatement ) : IQueryRequest
preparedPlan Couchbase.N1QL.QueryPlan The that was prepared beforehand.
originalStatement string The original statement (eg. SELECT * FROM default) that the user attempted to optimize
return IQueryRequest

Pretty() public method

Pretty print the output.
True by default.
public Pretty ( bool pretty ) : IQueryRequest
pretty bool True for the pretty.
return IQueryRequest

QueryRequest() public method

public QueryRequest ( ) : System
return System

QueryRequest() public method

public QueryRequest ( Couchbase.N1QL.QueryPlan plan, string originalStatement ) : System
plan Couchbase.N1QL.QueryPlan
originalStatement string
return System

QueryRequest() public method

public QueryRequest ( string statement ) : System
statement string
return System

ReadOnly() public method

If a GET request, this will always be true otherwise false.
Any value set here will be overridden by the type of request sent.
public ReadOnly ( bool readOnly ) : IQueryRequest
readOnly bool True for get requests.
return IQueryRequest

ScanConsistency() public method

Specifies the consistency guarantee/constraint for index scanning.
Optional.
StatementPlus are not currently supported by CouchbaseServer.
public ScanConsistency ( ScanConsistency scanConsistency ) : IQueryRequest
scanConsistency ScanConsistency Specify the consistency guarantee/constraint for index scanning.
return IQueryRequest

ScanWait() public method

Specifies the maximum time the client is willing to wait for an index to catch up to the vector timestamp in the request. If an index has to catch up, and the ScanWait time is exceed doing so, an error is returned.
Optional.
public ScanWait ( System.TimeSpan scanWait ) : IQueryRequest
scanWait System.TimeSpan The maximum time the client is willing to wait for index to catch up to the vector timestamp.
return IQueryRequest

Signature() public method

Includes a header for the results schema in the response.
The default is true.
public Signature ( bool includeSignature ) : IQueryRequest
includeSignature bool True to include a header for the results schema in the response.
return IQueryRequest

Statement() public method

Sets a N1QL statement to be executed.
Will erase a previous optimization of a statement using Prepared.
statement
public Statement ( string statement ) : IQueryRequest
statement string Any valid N1QL statement for a POST request, or a read-only N1QL statement (SELECT, EXPLAIN) for a GET request.
return IQueryRequest

Timeout() public method

Sets the maximum time to spend on the request.
Optional - the default is 0ms, which means the request runs for as long as it takes.
public Timeout ( System.TimeSpan timeOut ) : IQueryRequest
timeOut System.TimeSpan Maximum time to spend on the request
return IQueryRequest

ToString() public method

Returns a System.String that represents this instance.
public ToString ( ) : string
return string

UseStreaming() public method

Uses the streaming API for the returned results. This is useful for large result sets in that it limits the working size of the query and helps reduce the possibility of a OutOfMemoryException from occurring.
public UseStreaming ( bool streaming ) : IQueryRequest
streaming bool if set to true streams the results as you iterate through the response.
return IQueryRequest

Property Details

ScanConsistencyResolver public_oe static_oe property

public static Dictionary ScanConsistencyResolver
return string>.Dictionary