ADO.NET data provider
CoraDB.Data is the ADO.NET provider for CoraDB. It implements the CoraDB broker protocol in 100% managed C#: there is no native library and no P/Invoke, so the same assembly runs on Windows, Linux and macOS. It is a port of the CUBRID ADO.NET provider, which called the native CCI library.
It covers the standard ADO.NET surface — DbConnection, DbCommand, DbDataReader, DbTransaction, DbDataAdapter, DbCommandBuilder, DbProviderFactory, GetSchema — plus CoraDB extras: several brokers (alternative hosts) with load balancing, batch execution, typed parameters, LOBs, OIDs and collections, query cancel and timeouts, generated keys and query plans.
- Namespace:
CoraDB.Data.CoraDBClient; assembly:CoraDB.Data; target: .NET 8 (net8.0). - Every CoraDB data type, including the time-zone types (
TIMESTAMPTZ/LTZ,DATETIMETZ/LTZ), ENUM, JSON, SET / MULTISET / LIST, BLOB / CLOB and OBJECT (OID).
Install
Section titled “Install”Build the provider with the .NET 8 SDK and reference it from your project:
dotnet build CoraDB.Data.sln -c Release# then, in your project, either reference the project:# <ProjectReference Include="..\coradb-NET\src\CoraDB.Data\CoraDB.Data.csproj" /># or pack it and add the package:dotnet pack src/CoraDB.Data/CoraDB.Data.csproj -c Release -o artifactsdotnet add <your project> package CoraDB.Data --source ./artifactsTo use it through DbProviderFactories, register it once at startup:
DbProviderFactories.RegisterFactory(CoraDBClientFactory.InvariantName, CoraDBClientFactory.Instance);Connect
Section titled “Connect”using CoraDB.Data.CoraDBClient;
using var conn = new CoraDBConnection("server=localhost;port=33000;database=e-commerce;user=dba;password=");conn.Open();Console.WriteLine(conn.ServerVersion);Connection string
Section titled “Connection string”key=value; pairs; keywords are case-insensitive and synonyms are accepted. An empty value (key=) keeps the default. The JDBC/CCI URL form also works: cci:coradb:host:port:db:user:password:?key=value&key=value. Build strings safely with CoraDBConnectionStringBuilder.
| Keyword (synonyms) | Default | Meaning |
|---|---|---|
server (host, data source) |
localhost |
Broker host, or a list h1,h2:30001,[::1]:33000 |
port |
33000 |
Broker port for hosts without one |
database (db, initial catalog) |
Required | Database name |
user (uid, user id) |
public |
User name |
password (pwd) |
Empty | Password |
charset (encoding) |
utf-8 |
Connection character set |
autocommit |
true |
Auto-commit mode |
althosts |
— | Alternative brokers host:port,host:port, tried after the main hosts |
loadbalance |
false |
Shuffle the host list on connect |
maxConnectionRetryCount |
1 |
Extra rounds over the host list when connecting fails |
connectionTimeout (connect timeout) |
30 |
Connect timeout, in seconds |
loginTimeout |
— | Connect timeout, in milliseconds (JDBC style) |
queryTimeout |
0 |
Default CommandTimeout, in seconds; when not set, commands use 30 |
readTimeout |
0 |
Socket read timeout, in seconds (0 = none) |
usessl |
false |
Connect to an SSL broker (SSL=ON) |
sslValidateCertificate (validateCertificate) |
false |
Validate the broker's TLS certificate |
persistSecurityInfo |
false |
Keep the password in ConnectionString after Open() |
isolationLevel |
server | read committed, repeatable read, serializable |
lockTimeout |
server | Lock timeout in ms (-1 = infinite) |
holdCursors |
true |
Readers survive commits (holdable result sets) |
zeroDateTimeBehavior |
convertToNull |
How 0000-00-00 is read: convertToNull, round, exception |
enforceOldQueryProtocol |
false |
Use PREPARE + EXECUTE instead of PREPARE_AND_EXECUTE |
disconnectOnQueryTimeout |
false |
Close the connection when a query times out |
logSlowQueries, slowQueryThresholdMillis |
false, 60000 |
Log slow queries |
logTraceApi, logTraceNetwork, logFile, logBaseDir |
false |
Driver tracing |
Run queries
Section titled “Run queries”Parameters can be positional (?) or named (?name / @name); markers inside string literals, quoted identifiers and comments are ignored.
using (var cmd = new CoraDBCommand( "SELECT name, unit_price FROM product WHERE unit_price > ?min ORDER BY unit_price DESC LIMIT 3", conn)){ cmd.Parameters.AddWithValue("?min", 90m); using var reader = cmd.ExecuteReader(); while (reader.Read()) Console.WriteLine($"{reader.GetString(0)}: {reader.GetDecimal(1)}");}A graph query is an ordinary command:
using var cmd = new CoraDBCommand(@" SELECT b.name AS brand, COUNT(cu) AS followers FROM MATCH (cu:customer)-[:follows]->(b:brand) GROUP BY b.name ORDER BY followers DESC LIMIT ?", conn);cmd.Parameters.AddPositional(3);using var reader = cmd.ExecuteReader();while (reader.Read()) Console.WriteLine($"{reader["brand"]}: {reader["followers"]}"); // Nike: 209, Adidas: 132, Puma: 94Helper methods on the connection cover the common cases in one line:
int changed = conn.Execute("UPDATE product SET units_in_stock = ? WHERE id = ?", 25, 1379);List<Dictionary<string, object>> rows = conn.QueryAllAsObjects("SELECT code, name FROM countries ORDER BY name");DataTable table = conn.QueryToDataTable("SELECT * FROM orders WHERE shipped_date IS NULL");string plan = conn.GetQueryPlanOnly("SELECT * FROM orders WHERE order_date >= DATE'2025-12-01'");DbDataAdapter / DbCommandBuilder work as in any ADO.NET provider (CoraDBDataAdapter, CoraDBCommandBuilder).
Transactions
Section titled “Transactions”using (var tx = conn.BeginTransaction()){ conn.Execute("INSERT INTO orders (id, customer_id, order_date, shipping_cost, ship_address) VALUES (?, ?, SYSDATE, ?, ?)", 9001, 5, 4.90m, "Storgatan 1, Luleå"); tx.Save("lines"); conn.Execute("INSERT INTO order_items (order_id, product_id, quantity, discount_pct) VALUES (?, ?, ?, 0)", 9001, 1379, 2); // tx.Rollback("lines"); tx.Commit();}Commands created from the connection join its pending transaction. Isolation levels: ReadCommitted, RepeatableRead, Serializable; conn.LockTimeout sets the lock wait timeout.
Batches
Section titled “Batches”// many statements in one requestCoraDBBatchResult batch = conn.BatchExecute(new[] { "UPDATE product SET units_in_stock = units_in_stock + 10 WHERE id = 1379", "UPDATE product SET units_in_stock = units_in_stock + 5 WHERE id = 1224" });
// one statement, many parameter rows in one request: CoraDBCommand.ExecuteArray(...)Errors
Section titled “Errors”Errors are CoraDBException. ErrorCode is a driver code (ER_*, -21001…), a CAS code (CAS_ER_*, -10000…) or the server error number (for example -493 syntax error, -670 unique violation).
try{ conn.Execute("INSERT INTO countries (code, name) VALUES (?, ?)", "FRA", "France");}catch (CoraDBException ex){ Console.WriteLine($"[{ex.ErrorCode}] {ex.Message}");}When the connection breaks outside a transaction, the next request reconnects; a statement that may already have run (INSERT, UPDATE, COMMIT …) is never repeated. Inside a transaction the connection state becomes Broken: close it and open it again.
Migrating from the CUBRID ADO.NET provider
Section titled “Migrating from the CUBRID ADO.NET provider”- Replace the
CUBRID.Datareference withCoraDB.Data, and the namespaceCUBRID.Data.CUBRIDClientwithCoraDB.Data.CoraDBClient. - Rename the classes:
CUBRIDConnection→CoraDBConnection,CUBRIDCommand→CoraDBCommand,CUBRIDDataReader→CoraDBDataReader,CUBRIDException→CoraDBException, and so on. - Remove the native CCI DLLs from the deployment: they are no longer used.
- The
*Asyncmethods inherited from ADO.NET run synchronously; useTask.Runto keep a UI thread free.
API reference
Section titled “API reference”Every class, method and property — connection, command, parameters, data reader, transaction, adapter, command builder, factory, LOBs, OIDs, batch results, schema provider, errors, loggers and the type mapping — is in the ADO.NET data provider API reference.