Couchbase .NET SDK __CB_SDK_VERSION__

Show / Hide Table of Contents

Class AttemptContext

Provides methods that allow an application's transaction logic to read, mutate, insert, and delete documents.

Inheritance
object
AttemptContext
Inherited Members
object.GetType()
object.MemberwiseClone()
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
Namespace: Couchbase.Client.Transactions
Assembly: Couchbase.NetClient.dll
Syntax
public class AttemptContext

Properties

View Source

AttemptId

Gets the ID of this individual attempt.

Declaration
public string AttemptId { get; }
Property Value
Type Description
string
View Source

Logger

Gets the logger instance used for this AttemptContext.

Declaration
public ILogger<AttemptContext> Logger { get; }
Property Value
Type Description
ILogger<AttemptContext>
View Source

TransactionId

Gets the ID of this overall transaction.

Declaration
public string TransactionId { get; }
Property Value
Type Description
string

Methods

View Source

ConvertQueryError(Exception)

INTERNAL

Declaration
[InterfaceStability(Level.Volatile)]
public Exception? ConvertQueryError(Exception err)
Parameters
Type Name Description
Exception err

INTERNAL

Returns
Type Description
Exception

INTERNAL

View Source

GetAsync(ICouchbaseCollection, string, TransactionGetOptionsBuilder?)

Gets a document.

Declaration
public Task<TransactionGetResult> GetAsync(ICouchbaseCollection collection, string id, TransactionGetOptionsBuilder? options = null)
Parameters
Type Name Description
ICouchbaseCollection collection

The collection to look up the document in.

string id

The ID of the document.

TransactionGetOptionsBuilder options

Optional instance of TransactionGetOptionsBuilder

Returns
Type Description
Task<TransactionGetResult>

A TransactionGetResult containing the document.

Exceptions
Type Condition
DocumentNotFoundException

If the document does not exist.

View Source

GetMulti(List<TransactionGetMultiSpec>, TransactionGetMultiOptionsBuilder?)

Declaration
[InterfaceStability(Level.Volatile)]
public Task<TransactionGetMultiResult> GetMulti(List<TransactionGetMultiSpec> specs, TransactionGetMultiOptionsBuilder? options = null)
Parameters
Type Name Description
List<TransactionGetMultiSpec> specs
TransactionGetMultiOptionsBuilder options
Returns
Type Description
Task<TransactionGetMultiResult>
View Source

GetMultiReplicaFromPreferredServerGroup(List<TransactionGetMultiReplicaFromPreferredServerGroupSpec>, TransactionGetMultiReplicaFromPreferredServerGroupOptionsBuilder?)

Declaration
[InterfaceStability(Level.Volatile)]
public Task<TransactionGetMultiReplicaFromPreferredServerGroupResult> GetMultiReplicaFromPreferredServerGroup(List<TransactionGetMultiReplicaFromPreferredServerGroupSpec> specs, TransactionGetMultiReplicaFromPreferredServerGroupOptionsBuilder? options = null)
Parameters
Type Name Description
List<TransactionGetMultiReplicaFromPreferredServerGroupSpec> specs
TransactionGetMultiReplicaFromPreferredServerGroupOptionsBuilder options
Returns
Type Description
Task<TransactionGetMultiReplicaFromPreferredServerGroupResult>
View Source

GetOptionalAsync(ICouchbaseCollection, string)

Declaration
public Task<TransactionGetResult?> GetOptionalAsync(ICouchbaseCollection collection, string id)
Parameters
Type Name Description
ICouchbaseCollection collection
string id
Returns
Type Description
Task<TransactionGetResult>
View Source

GetOptionalAsync(ICouchbaseCollection, string, TransactionGetOptionsBuilder?)

Declaration
public Task<TransactionGetResult?> GetOptionalAsync(ICouchbaseCollection collection, string id, TransactionGetOptionsBuilder? options = null)
Parameters
Type Name Description
ICouchbaseCollection collection
string id
TransactionGetOptionsBuilder options
Returns
Type Description
Task<TransactionGetResult>
View Source

GetOptionalAsync(ICouchbaseCollection, string, IRequestSpan?)

Gets a document or null.

Declaration
public Task<TransactionGetResult?> GetOptionalAsync(ICouchbaseCollection collection, string id, IRequestSpan? parentSpan)
Parameters
Type Name Description
ICouchbaseCollection collection

The collection to look up the document in.

string id

The ID of the document.

IRequestSpan parentSpan

The optional parent tracing span.

Returns
Type Description
Task<TransactionGetResult>

A TransactionGetResult containing the document, or null if not found.

View Source

GetReplicaFromPreferredServerGroup(ICouchbaseCollection, string, TransactionGetOptionsBuilder?)

This gets from the preferred group, assuming one was set when configuring the cluster this transaction is using.

Declaration
public Task<TransactionGetResult?> GetReplicaFromPreferredServerGroup(ICouchbaseCollection collection, string id, TransactionGetOptionsBuilder? options = null)
Parameters
Type Name Description
ICouchbaseCollection collection

Collection where the document should reside.

string id

The ID of the document you wish to get.

TransactionGetOptionsBuilder options

Options to use when getting TransactionGetOptionsBuilder

Returns
Type Description
Task<TransactionGetResult>

TransactionGetResult representing the document.

Exceptions
Type Condition
TransactionOperationFailedException
FeatureNotAvailableException

Raised when the cluster doesn't support this feature.

DocumentUnretrievableException

Raised when the document was not found in the replicas.

View Source

InsertAsync(ICouchbaseCollection, string, object, TransactionInsertOptionsBuilder?)

Declaration
public Task<TransactionGetResult> InsertAsync(ICouchbaseCollection collection, string id, object content, TransactionInsertOptionsBuilder? options = null)
Parameters
Type Name Description
ICouchbaseCollection collection
string id
object content
TransactionInsertOptionsBuilder options
Returns
Type Description
Task<TransactionGetResult>
View Source

InsertAsync(ICouchbaseCollection, string, object, IRequestSpan?)

Insert a document.

Declaration
public Task<TransactionGetResult> InsertAsync(ICouchbaseCollection collection, string id, object content, IRequestSpan? parentSpan)
Parameters
Type Name Description
ICouchbaseCollection collection

The collection to insert the document into.

string id

The ID of the new document.

object content

The content of the new document.

IRequestSpan parentSpan

The optional parent tracing span.

Returns
Type Description
Task<TransactionGetResult>

A TransactionGetResult representing the inserted document.

View Source

QueryAsync<T>(string, TransactionQueryConfigBuilder?, IScope?, IRequestSpan?)

Run a query in transaction mode.

Declaration
public Task<IQueryResult<T>> QueryAsync<T>(string statement, TransactionQueryConfigBuilder? config = null, IScope? scope = null, IRequestSpan? parentSpan = null)
Parameters
Type Name Description
string statement

The statement to execute.

TransactionQueryConfigBuilder config

The configuration to use for this query.

IScope scope

The scope

IRequestSpan parentSpan

The optional parent tracing span.

Returns
Type Description
Task<IQueryResult<T>>

A SingleQueryTransactionResult<T> with the query results, if any.

Type Parameters
Name Description
T

The type of the result. Use object for queries with no results.

Remarks

IMPORTANT: Any KV operations after this query will be run via the query engine, which has performance implications.

View Source

QueryAsync<T>(string, TransactionQueryOptions, IScope?, IRequestSpan?)

Run a query in transaction mode.

Declaration
public Task<IQueryResult<T>> QueryAsync<T>(string statement, TransactionQueryOptions options, IScope? scope = null, IRequestSpan? parentSpan = null)
Parameters
Type Name Description
string statement

The statement to execute.

TransactionQueryOptions options

The query options to use for this query.

IScope scope

The scope

IRequestSpan parentSpan

The optional parent tracing span.

Returns
Type Description
Task<IQueryResult<T>>

A SingleQueryTransactionResult<T> with the query results, if any.

Type Parameters
Name Description
T

The type of the result. Use object for queries with no results.

Remarks

IMPORTANT: Any KV operations after this query will be run via the query engine, which has performance implications.

View Source

RemoveAsync(TransactionGetResult, IRequestSpan?)

Remove a document previously looked up in this transaction.

Declaration
public Task RemoveAsync(TransactionGetResult doc, IRequestSpan? parentSpan = null)
Parameters
Type Name Description
TransactionGetResult doc

The TransactionGetResult of a document previously looked up in this transaction.

IRequestSpan parentSpan

The optional parent tracing span.

Returns
Type Description
Task

A task representing the asynchronous work.

View Source

ReplaceAsync(TransactionGetResult, object, TransactionReplaceOptionsBuilder?)

Declaration
public Task<TransactionGetResult> ReplaceAsync(TransactionGetResult doc, object content, TransactionReplaceOptionsBuilder? options = null)
Parameters
Type Name Description
TransactionGetResult doc
object content
TransactionReplaceOptionsBuilder options
Returns
Type Description
Task<TransactionGetResult>
View Source

ReplaceAsync(TransactionGetResult, object, IRequestSpan?)

Replace the content of a document previously fetched in this transaction with new content.

Declaration
public Task<TransactionGetResult> ReplaceAsync(TransactionGetResult doc, object content, IRequestSpan? parentSpan)
Parameters
Type Name Description
TransactionGetResult doc

The TransactionGetResult of a document previously looked up in this transaction.

object content

The updated content.

IRequestSpan parentSpan

The optional parent tracing span.

Returns
Type Description
Task<TransactionGetResult>

A TransactionGetResult reflecting the updated content.

Extension Methods

Extensions.QueryAsync<T>(AttemptContext, string, Action<TransactionQueryOptions>?, IScope?)
  • View Source
In this article
Back to top Copyright © 2020 Couchbase, Inc. All rights reserved.