System.Data / ADO.NET available
A standard ADO.NET provider in H2Sharp.Data (System.Data.Common). It is measured against the inherited AdoNet.Specification.Tests conformance suite and by a green Dapper flow — not against itself.
Types
| Type | Base | Notes |
|---|---|---|
H2Connection | DbConnection | Also exposes CurrentDatabase (the engine's Database) for engine-level work. |
H2Command | DbCommand | ExecuteNonQuery, ExecuteScalar, ExecuteReader, their Async forms, Prepare, Cancel, Parameters. |
H2Parameter | DbParameter | Parameters travel beside the text — they are never concatenated into it. |
H2DataReader | DbDataReader | Full typed getter set, GetBytes/GetChars, GetSchemaTable. |
H2Transaction | DbTransaction | Works. Wraps an engine Tx.Transaction: Commit, Rollback, IsolationLevel. Statements commit at the reference's points, so a single DML statement is durable on its own and auto-commit is fixed. |
H2DataAdapter | DbDataAdapter | Fill / update from a select command, for DataSet-style code. |
H2CommandBuilder | DbCommandBuilder | Builds insert / update / delete commands for a table. |
H2ConnectionStringBuilder | DbConnectionStringBuilder | DataSource, UserId, Password, ToH2ConnectionString(). |
H2ProviderFactory | DbProviderFactory | Entry point for DI and tooling: H2ProviderFactory.Instance. |
Connection strings
Both spellings are accepted, because a caller will use whichever their code base already has. The jdbc:h2: prefix is stripped and not re-added, so Data Source=mem:x and Data Source=jdbc:h2:mem:x open the same database — the name itself is kept byte for byte, because the name decides which database is opened.
Data Source=mem:mydb // ADO.NET spelling
Data Source=jdbc:h2:mem:mydb // H2 spelling, same database
new H2ConnectionStringBuilder("jdbc:h2:mem:mydb").ToH2ConnectionString()
Registration
services.AddDbConnectionFactory<H2ProviderFactory>(_ => new H2ProviderFactory());
// or construct directly:
await using var con = new H2Connection("jdbc:h2:mem:mydb");
Transactions
using var tx = con.BeginTransaction();
con.Execute("INSERT INTO PERSON VALUES(@Id, @Name)", new { Id = 2, Name = "Grace" });
tx.Commit(); // or tx.Rollback()
Not implemented yet
Honest list — these throw TODOException or are absent, by design at this stage:
ChangeDatabase— throwsTODOException.- Connection-level
GetSchema()overINFORMATION_SCHEMA— not there yet. (H2DataReader.GetSchemaTable()is a different thing and does work.) - File databases and async
OpenAsync. - No batches —
CanCreateBatchisfalse. - No data-source enumerator —
CanCreateDataSourceEnumeratorisfalse. - File databases and async
OpenAsync.
See also Dapper for the live end-to-end flow, and port status for phases.