OceanBase
English日本語简体中文
Docs Home
Products
Integrations
Release Notes

Databases

OceanBase DatabaseOceanBase Cloud OceanBase Best Practices

Tools

OceanBase Cloud PlatformOceanBase Migration ServiceOceanBase Developer CenterOceanBase Migration AssessmentOceanBase Admin ToolOceanBase Loader and DumperOceanBase DeployerKubernetes operator for OceanBaseOceanBase Diagnostic Tool OceanBase Binlog Service

Connectors and Middleware

OceanBase Database Proxy OceanBase Connector/C OceanBase Connector/J OceanBase Connector/ODBC OceanBase Connector/NETOceanBase Command-Line Client

Databases

OceanBase DatabaseOceanBase Cloud OceanBase Best Practices

Connectors and Middleware

OceanBase Database Proxy OceanBase Connector/C OceanBase Connector/J OceanBase Connector/ODBC OceanBase Connector/NETOceanBase Command-Line Client

Tools

OceanBase Cloud PlatformOceanBase Migration ServiceOceanBase Developer CenterOceanBase Migration AssessmentOceanBase Admin ToolOceanBase Loader and DumperOceanBase DeployerKubernetes operator for OceanBaseOceanBase Diagnostic Tool OceanBase Binlog Service
OceanBase DatabaseOceanBase Cloud ToolsConnectors and MiddlewareLifecycle Support Policy

OceanBase Connector/NET

V1.3.1
  • What Is OceanBase Connector/NET
    • Introduction to OceanBase Connector/NET
  • Install and Connect
    • Installation process
    • Test the connection
    • Package reference and usage
    • Compatibility impact
  • User Guide
    • Quick Start
      • Complete example
    • Connection Strings and Data Source
      • Connection string
    • Data Types
      • Overview of data types
    • Command and Parameter
      • Overview
      • ArrayBinding
      • AutoCommit and Transactions
    • Result Set
      • Result set types
    • ORM and Frameworks
      • Use Entity Framework Core
      • Use SqlSugar
      • Use FreeSql
      • Use the ABP Framework
  • Reference Information
    • Common Interfaces
      • Overview of commonly used interfaces
  • Version Release Records
    • OceanBase Connector/NET V1.0.0
    • OceanBase Connector/NET V1.1.0
    • OceanBase Connector/NET V1.2.0
    • OceanBase Connector/NET V1.3.1

Download PDF

Document Feedback
  1. Documentation Center
  2. OceanBase Connector/NET
  3. V1.3.1

AutoCommit and Transactions

Last Updated:2026-09-22 03:13:33

Connection String and Runtime Properties
Recommended Usage (Connection string defaults to AutoCommit=true)
TransactionScope.Suppress + Regular DML + ArrayBinding
Single Primary Table Row + Detail ArrayBinding (No Requirement for Same DB Transaction)
Primary Table + Detail in Same DB Transaction
Summary of Property Semantics
Common misconceptions
References

In Oracle-compatible mode, OceanBase Connector/NET provides the OracleConnection.AutoCommit property, which is aligned with ODP.NET AutoCommit.

Connection String and Runtime Properties

Concepts
Description
Connection StringAutoCommit Initial Default Value (Defaulttrue) and is restored to this value when the connection pool is reset.
OracleConnection.AutoCommit Current Session Value: Can be set before and after opening a connection.

Note

If the application does not set runtime properties, its behavior will be consistent with older versions configured only via the connection string, and this does not constitute a compatibility change.

Recommended Usage (Connection string defaults to AutoCommit=true)

TransactionScope.Suppress + Regular DML + ArrayBinding

// Connection string: AutoCommit=true (default), UseArrayBinding=true
using (var scope = new TransactionScope(TransactionScopeOption.Suppress))
{
    using var conn = new OracleConnection(connStr);
    conn.Open();

    AuditInsert(conn);               // Normal DML: auto-commit

    conn.AutoCommit = false;         // Set after connecting to meet the prerequisite for ArrayBinding.
    ArrayBindInsert(conn);
    conn.AutoCommit = true;          // Required: Commit the batch and restore automatic commit.

    scope.Complete();
}

Reasons for Explicit Recovery or Commit: Regular DML and batch operations generated while AutoCommit=false are uncommitted will be rolled back when the connection is closed. When using the runtime switching method above, setting conn.AutoCommit back to true will first commit the implicit transaction and then restore automatic commit.

Single Primary Table Row + Detail ArrayBinding (No Requirement for Same DB Transaction)

conn.Open();                         // Connection string AutoCommit=true

UpdateMainTable(conn);               // Single UPDATE, already automatically committed

conn.AutoCommit = false;
ArrayBindDetailRows(conn);
conn.AutoCommit = true;              // Commit detail batch

Primary Table + Detail in Same DB Transaction

conn.AutoCommit = false;             // Must be done before BeginTransaction
using (var tx = conn.BeginTransaction())
{
    UpdateMainTable(conn, tx);
    ArrayBindDetailRows(conn, tx);
    tx.Commit();
}
conn.AutoCommit = true;

Summary of Property Semantics

Action
Behavior
After the connection is established, set it tofalse ExecuteSET autocommit=0
After the connection is established, set it totrue When no explicit local transaction is present, an implicit transaction is first committed, and then the operation is executed.SET autocommit=1
Explicit transaction end ViaCommit()orRollback()Restore the AutoCommit value before the transaction started after the transaction is ended.
Distributed transactions are registered or active.OracleTransactionSet at Thrown WhenInvalidOperationException

Common misconceptions

Misunderstanding
actual
AutoCommitCan only be set before opening a connection ODP.NET semantics allow setting this after the connection is opened.
scope.Complete()Alternative Database Commit Complete()Only marks the success of an environment transaction and cannot replace a driver-side commit.
ArrayBinding must be set in the connection string.AutoCommit=false It is only required that the current session has autocommit=0; this setting can also be configured at runtime.conn.AutoCommit=false
BeginTransaction()Alternative session autocommit=0 No; the driver will refuse to execute, and under legacy behavior, you may also receive a server-side error.-4007Error

References

  • ArrayBinding
  • Connection string

Previous topic

ArrayBinding
Last

Next topic

Result set types
Next
on this page
Connection String and Runtime Properties
Recommended Usage (Connection string defaults to AutoCommit=true)
TransactionScope.Suppress + Regular DML + ArrayBinding
Single Primary Table Row + Detail ArrayBinding (No Requirement for Same DB Transaction)
Primary Table + Detail in Same DB Transaction
Summary of Property Semantics
Common misconceptions
References