Connect from .NET (Framework or Core) via the in-box System.Data.Odbc provider.
new OdbcConnection("DSN=DeltaForge;Uid=...;Pwd=...")
## Install `System.Data.Odbc` is in-box for .NET Framework. For .NET (Core) 5+, install the package: ``` dotnet add package System.Data.Odbc ``` The package wraps the native ODBC entry points. On Linux and macOS it talks to the OS driver manager (unixODBC / iODBC) the same way other ODBC clients do; install the Delta Forge driver the usual way. ## Pattern: per-column natural type .NET's `OdbcDataReader` issues each `SQLGetData` call at the column's natural C type: DOUBLE for double-precision, NUMERIC for decimals, SBIGINT for 64-bit integers, and so on. The driver is tuned for this access pattern; calling `reader.GetValue(i)` on a wide result is fast. Do not use `reader.GetSqlValue` family methods (no equivalent exists on `OdbcDataReader`); the in-box `Get<Type>(i)` accessors are the canonical path. ## Async `OdbcConnection` and `OdbcCommand` expose `OpenAsync`, `ExecuteReaderAsync`, etc. The driver does not natively support ODBC async mode (`SQL_ATTR_ASYNC_ENABLE`); the Async methods are convenience wrappers that schedule the synchronous call on a worker thread. This is fine for typical workloads; for very high-fan-out, prefer running multiple synchronous connections in parallel. ## Transactions Wrap multi-statement work in a transaction: ``` using var tx = cn.BeginTransaction(); cmd.Transaction = tx; cmd.ExecuteNonQuery(); // ... tx.Commit(); ``` The driver maps `BeginTransaction` to `SQLEndTran` semantics; commits and rollbacks are durable per the engine's transaction model. The default isolation level is `READ_COMMITTED`; override via `BeginTransaction(IsolationLevel.Snapshot)` if your workload needs it. ## Performance and `IsDBNull` If you observe unexpectedly slow `IsDBNull` performance, ensure the driver build is recent. Older builds had a per-cell overhead on wide result sets; current builds are tuned for the .NET access pattern. If the driver-side path is fast but the application is still slow, the residual time is typically in the driver manager's ODBC trace or a layer above System.Data.Odbc. Disable driver-manager tracing in production. ## Entity Framework The Microsoft EF team does not ship an ODBC provider for EF Core. Third-party providers exist but are not part of Delta Forge's tested matrix. For richer ORM integration, use a thin Dapper layer over `OdbcConnection`; Dapper does not assume EF semantics and works well over ODBC.
using System.Data.Odbc;
var cs = "DSN=DeltaForge;Uid=alice@example.com;Pwd=hunter2";
using var cn = new OdbcConnection(cs);
cn.Open();
using var cmd = cn.CreateCommand();
cmd.CommandText = "SELECT * FROM analytics.marts.fact_orders LIMIT 100";
using var rdr = cmd.ExecuteReader();
while (rdr.Read())
{
Console.WriteLine(rdr.GetValue(0));
}
// Parameterised query
cmd.CommandText = "SELECT * FROM customers WHERE id = ? AND status = ?";
cmd.Parameters.AddWithValue("id", 42);
cmd.Parameters.AddWithValue("status", "active");