MongoDB · Types · Services and connections

ArxMongoConnection

Definition

Namespace
ARX.SDK.MongoDb.Services
Package
ARX.SDK.MongoDb
C#
public sealed class ArxMongoConnection : ArxConnection

A MongoDB connection for ARX transactions. Application code begins a transaction on it and passes the transaction to ArxMongoDbService calls; it never needs a driver type.

Constructor

  • ArxMongoConnection(ArxMongoDbService service)

    A connection on the service's client and database.

    Parameter Type Description
    serviceArxMongoDbServiceThe service whose calls will take the transaction.
  • ArxMongoConnection(string connectionString)

    A connection for the database a connection string names (a service is made for it).

    Parameter Type Description
    connectionStringstringA MongoDB connection string naming the database.

Usage

C#

A line from a verified sample; the full, runnable code is on its page.

await using var connection = new ArxMongoConnection(service);

Create in an ARX transaction, scenario 1

Used in:

Notes

It holds a driver session on the service's client. Transactions need a replica set or a sharded cluster: on a standalone server BeginTransactionAsync is ARX8001. A transaction reads a snapshot and commits with write concern majority. MongoDB has no savepoints, and a failed call aborts the whole transaction on the server, so a failure makes it IsAborted (later calls are ARX1015). One transaction at a time, one call at a time; not thread-safe. MongoDB ends a transaction that stays open longer than transactionLifetimeLimitSeconds (60 s by default).