---
title: CodeTableMap
summary: API reference for CodeTableMap.
status: draft
owner: <owner>
last_reviewed: 2026-07-23
library: SAIF.Framework.CodeGen
reference_type: package
---

# CodeTableMap

`CodeTableMap` is the sole public class in `SAIF.Framework.CodeGen`. It connects directly to an Oracle data layer, queries a caller-supplied "code table" for `code`/`code_descr` reference rows, and generates VB.NET source-code text — either `Case` statement blocks or `Enum` member lists — for a developer to paste into hand-written code.

## Purpose
- Owns the Oracle connection lifecycle, SQL execution, and source-text generation for code-table-driven VB source generation.
- Is a standalone tooling class, not a `clsBusinessBase`/`clsBusinessCollectionBase` business object.

## Context
- Namespace: `SAIF.Framework.CodeGen`
- Assembly/package: `SAIF.Framework.CodeGen` (bundled into the `SAIF.BOF.Framework` NuGet package via the `SAIF.Framework.Core` nuspec glob)

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| New | `Public Sub New(dbUser As String, database As String)` | Constructor; calls `Connect` to establish the Oracle data-portal connection |
| CreateCaseStatement | `Public Function CreateCaseStatement(table As String, enumName As String, rowItem As String, Optional useDescriptionAsCode As Boolean = True, Optional tabIndex As Integer = 0) As String` | Generates a VB `Case` statement block from a code table's rows |
| CreateEnumStatement | `Public Function CreateEnumStatement(table As String, enumName As String, includeNull As Boolean, Optional useDescriptionAsCode As Boolean = True, Optional tabIndex As Integer = 0) As String` | Generates a VB `Enum` member list from a code table's rows |
| Connect | `Protected Sub Connect(dbUser As String, database As String)` | Establishes or refreshes the Oracle data-layer connection (`m_dpi`); only reconnects when `dbUser`/`database` differ from the current connection |

<!-- Private helper methods (GetResult, GetEnumValue) are not part of the public surface; their behavior is described in Behavioral notes below. -->

## Behavioral notes
- `CreateCaseStatement` and `CreateEnumStatement` both call the private `GetResult(table)` helper, which builds and executes `select code, code_descr from {table}` via `SqlHelper.ResultSetQuery(m_dpi).Execute(sql)`.
- The private `GetEnumValue` helper derives a unique, legal VB identifier from each row's `code`/`code_descr` values: it strips non-alphabetic characters from `code_descr` when `useDescriptionAsCode` is true (default), prefixes purely numeric identifiers with `"Code"`, and appends the raw `code` value to disambiguate duplicate identifiers within a generated block — see [BR-001](../business-rules.md#br-001-enum-member-identifiers-must-be-unique-within-a-generated-block), [BR-002](../business-rules.md#br-002-generated-enum-member-identifiers-must-be-legal-vb-identifiers), and [BR-003](../business-rules.md#br-003-enum-member-identifier-derivation-strips-non-alphabetic-characters-from-the-description).
- `Connect` only reconstructs `clsMSOracleDataLayer` when `dbUser` or `database` differ from the current connection — see [BR-004](../business-rules.md#br-004-data-connection-is-only-re-established-when-parameters-change).
- No callers of `CodeTableMap` were found anywhere in this repository; it appears to be invoked interactively/manually rather than as part of any runtime request pipeline**.

## Constraints and usage notes
- The `table` parameter is interpolated directly into SQL text via `String.Format`, not passed as a bound parameter; callers are responsible for supplying a valid, trusted table name.
- Only a read (`SELECT`) operation is supported; this class has no write/insert/update/delete capability.
- Requires an Oracle connection reachable via `clsMSOracleDataLayer(dbUser, database)`; no configuration-file-driven connection settings exist in this library.

> **Note:** Statements marked with * were inferred from code structure, naming conventions, or
> contextual evidence where direct confirmation was not available in source artifacts. Statements
> marked with ** could not be confirmed; treat as unknown until verified.

## Sources
- SAIF.Framework.CodeGen\CodeTableMap.vb
