Releases for RepoDb.Db2
View the NuGet package here or download it directly here.
RepoDb.Db2 (v0.0.1-alpha) - Preview
Released: TBA
New
First (alpha) release of the Db2 provider for RepoDB, built on top of the IBM Data Server .NET Provider (Net.IBM.Data.Db2). Targets Db2 for Linux, UNIX, and Windows (LUW) 10.5 and later, and .NET 8, .NET 9, and .NET 10.
What’s included
- Db2Bootstrap / Db2GlobalConfiguration
.UseDb2()— initializes RepoDB for use withDB2Connection(GlobalConfiguration.Setup().UseDb2()), mapping the Db2DbSetting, Db2DbHelper, and Db2StatementBuilder to everyDB2Connection. - Db2DbSetting — Db2-specific behavior:
"for opening/closing identifier quotes,:parameter prefix, no table hints, no native upsert (Mergeis hand-built instead), and multi-statement command text support (IsMultiStatementExecutable = true,MultiStatementSeparator = ";"). - Db2StatementBuilder — generates Db2-flavored SQL for every operation:
OFFSET ... FETCH NEXT ... ROWS ONLYpaging for BatchQuery/skip-take queries,FETCH FIRST n ROWS ONLYfor Exists and top-N Query,MERGE INTO ... USING (SELECT ... FROM SYSIBM.SYSDUMMY1) ...for Merge/MergeAll, a genuine multi-rowVALUES (...), (...)list for batched InsertAll,TRUNCATE TABLE ... IMMEDIATE, and identity/primary-key retrieval viaSELECT ... FROM FINAL TABLE (INSERT ...)forInsert/InsertAllplus a follow-up same-command-textSELECTforMerge/MergeAll(Db2 LUW’sMERGEhas noFINAL TABLEsupport). - Db2DbHelper — schema/type discovery (
GetFields/GetFieldsAsync) sourced fromSYSCAT.COLUMNS, and generated-identity retrieval (GetScopeIdentity/GetScopeIdentityAsync) viaIDENTITY_VAL_LOCAL()against Db2’s single-row dummy tableSYSIBM.SYSDUMMY1. - Resolvers — Db2ConvertFieldResolver (casts a field to its Db2 type when a conversion is needed, e.g. typed ExecuteQuery results), Db2DbTypeNameToClientTypeResolver (maps
SYSCAT.COLUMNS.TYPENAMEvalues to .NET CLR types), and DbTypeToDb2StringNameResolver (mapsSystem.Data.DbTypeto Db2 SQL type names, e.g.DbType.Guid→CHAR(16) FOR BIT DATA). - Property handlers — Db2GuidToByteArrayPropertyHandler (maps a
Guidproperty to/fromCHAR(16) FOR BIT DATA, since Db2 has no native GUID type) and Db2ByteToInt16PropertyHandler (maps abyteproperty to/fromSMALLINT, since Db2 has no native single-byte integer type). - Parameter attributes mirroring
DB2Parametermembers, settable per entity property: Db2Type, Db2TypeOutput, ArrayLength, IsDefault, IsUnassigned, SourceColumn, SourceColumnNullMapping, and SourceVersion. - QueryMultiple/
QueryMultipleAsyncrun as a single combined, multi-statement command text ("SELECT ... T1; SELECT ... T2"), the same as SQL Server/MySQL/PostgreSQL — no per-type round trip.
Known limitations (v1)
- Every statement binds parameters using
:Name-style host variables. IBM’s Data Server .NET Provider disables host-variable support by default, so the connection string must includeHostVarParameters=True;, otherwise every parameterized call fails withDB2ExceptionSQL0313N. - InsertAll/MergeAll/UpdateAll batch multiple entities into a single round trip, but
InsertAll’s row-to-identity correlation relies on an assumption not yet verified against a live Db2 instance: thatFINAL TABLE’s result rows preserve the sourceVALUESlist order. Verify thoroughly before relying on it in production. MergeAllthrowsNotSupportedExceptionfor abatchSizegreater than 1 when the identity column is used as a qualifier, since a freshly-inserted row’s caller-bound qualifier value can’t be safely re-correlated within a mixed matched/unmatched batch. Pass an explicit non-identity qualifier, or call withbatchSize: 1.Merge’s generated-key retrieval falls back to re-readingMAX(<key>)off the table rather thanIDENTITY_VAL_LOCAL(), since Db2 LUW’s per-statement autocommit clears that register before the follow-upSELECTruns — a best-effort read, not a guarantee, if another connection concurrently inserts into the same table.Merge/MergeAllagainst tables with several LOB columns can fail withSQL1585N(system temporary tablespace too small); provisioning a 32K-page temporary tablespace works around it. XML-mapped fields are not supported inMerge/MergeAllat all.- No native GUID/
UNIQUEIDENTIFIERtype — map aGuidproperty asbyte[], or register Db2GuidToByteArrayPropertyHandler per-property. - The published package only references the Windows driver package (
Net.IBM.Data.Db2) transitively. Linux, macOS, and other non-Windows consumers must add the matchingNet.IBM.Data.Db2-*package themselves — see Get Started for Db2. Db2 for z/OS and Db2 for i are not currently tested against — only Db2 LUW 10.5 and later.
- Referenced the
RepoDbpackagev1.16.0. - Referenced the
Net.IBM.Data.Db2/Net.IBM.Data.Db2-lnxpackagev9.0.0.400(v10.0.0.200on .NET 10).