Method PrepareAsync
PrepareAsync(String, PrepareOptions, CancellationToken)
Prepares a query for execution and reuse.
Declaration
public Task<PreparedStatement> PrepareAsync(string statement, PrepareOptions options = null, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
String | statement | Query SQL statement. |
PrepareOptions | options | (Optional) Options for the Prepare
operation. If not specified or null , appropriate defaults
will be used. See PrepareOptions. |
CancellationToken | cancellationToken | (Optional) Cancellation token. |
Returns
Type | Description |
---|---|
Task<PreparedStatement> | Task returning PreparedStatement. |
Remarks
Query preparation allows queries to be compiled(prepared) and reused, saving time and resources. Use of prepared queries vs direct execution of query strings is highly recommended.
See QueryAsync for general information and restrictions. Prepared queries are implemented as PreparedStatement which supports bind variables in queries which can be used to more easily reuse a query by parameterization.
Exceptions
Type | Condition |
---|---|
ArgumentException | If
statement is null or invalid or
options contains invalid values.
|
TimeoutException | Operation has timed out. |
InvalidOperationException | The table or the service is not in a valid state to perform this operation. |
NoSQLException | NoSQLException or one of its subclasses is thrown if operation cannot be performed for any other reason. See documentation for corresponding subclass of NoSQLException. |