---
title: "SQL-161: Retrieve DocumentOptionCode via GetDocumentOptionCodes"
summary: Read operation against DocumentOptionCode via NHibernate ORM.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-09-24
library: SAIF.Services
reference_type: package
---

# SQL-161: Retrieve DocumentOptionCode via GetDocumentOptionCodes

This statement performs an unfiltered read of the `DOCUMENT_OPTION_CODE` lookup table, materializing every document option code available for template configuration.

## Classification

| Field | Value |
| --- | --- |
| **SQL ID** | SQL-161 |
| **Operation type** | Read |
| **Execution method** | ORM (NHibernate LINQ) |
| **Database** | Oracle |
| **Schema** | [unqualified]** |
| **Command type** | N/A (ORM-generated) |
| **Business object** | `DocumentOptionCode` |
| **Criteria property** | N/A — ORM |
| **Lifecycle method** | `GetDocumentOptionCodes` |

## Parameters

None (unfiltered full-table read).

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [DOCUMENT_OPTION_CODE](../database-tables.md#document_option_code) | SELECT | CODE, CODE_DESCR, TEMPLATE_DEFAULT_FLAG, UPDATE_DATE, UPDATE_USER, UPDATE_NUM |

## LINQ statement

Source: `Services/SAIF.Services/Documents/TemplateSearchService.cs:113`

```csharp
var codeRecords = unitOfWork.GetRepository<DocumentOptionCode>().Query().ToList();
```

## Sample SQL

> **Inferred SQL:** This SQL was inferred from the LINQ statement above and the NHibernate mappings. It is not concrete SQL from source code; NHibernate generates the executed statement at runtime, so aliases, column order, join syntax, and bind-parameter names may differ.

```sql
-- Inferred from LINQ (NHibernate mapping translation); not concrete SQL
SELECT DOC.CODE,
       DOC.CODE_DESCR,
       DOC.TEMPLATE_DEFAULT_FLAG,
       DOC.UPDATE_DATE,
       DOC.UPDATE_USER,
       DOC.UPDATE_NUM
FROM   DOCUMENT_OPTION_CODE DOC;
```

Translation notes:
- Unfiltered full-table read materialized by `ToList()`; `TEMPLATE_DEFAULT_FLAG` is `YesNoType` (`'Y'`/`'N'`).

## Operations and processes
- TemplateSearchService.GetDocumentOptionCodes — see [Operations and processes](../operations-processes.md)

## Sources
- `Services/SAIF.Services/Documents/TemplateSearchService.cs (L113)`
