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

# SQL-082: Retrieve ApplicationCode via ValidateApplicationCode

This ORM statement performs a read operation on `ApplicationCode` via `IUnitOfWork.GetRepository<T>()`, executed from `Services/SAIF.Services/OnlineMessages/OnlineMessagesApiService.cs (L123)`.

## Classification

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

## Parameters

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| `application.Trim().ToUpper()` | Input | ** | N/A | `x.Code == application.Trim().ToUpper()` → column CODE |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [ONLINE_MESSAGE_APP_CODE](../database-tables.md#online_message_app_code) | SELECT | `CODE`, `CODE_DESCR`, `UPDATE_DATE`, `UPDATE_NUM`, `UPDATE_USER` |

## LINQ statement

Source: `Services/SAIF.Services/OnlineMessages/OnlineMessagesApiService.cs:122`

```csharp
// Services/SAIF.Services/OnlineMessages/OnlineMessagesApiService.cs:122-123
            var applicationCode =
                _unitOfWork.GetRepository<ApplicationCode>().Query().FirstOrDefault(x => x.Code == application.Trim().ToUpper());
```

## 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
-- Services/SAIF.Services/OnlineMessages/OnlineMessagesApiService.cs:123
SELECT *
FROM (
  SELECT
    OMAC.CODE,
    OMAC.CODE_DESCR,
    OMAC.UPDATE_DATE,
    OMAC.UPDATE_NUM,
    OMAC.UPDATE_USER
  FROM ONLINE_MESSAGE_APP_CODE OMAC
  WHERE OMAC.CODE = :application
)
WHERE ROWNUM <= 1
```

Translation notes:
- `application.Trim().ToUpper()` operates on a captured method argument, not a mapped column; NHibernate's partial evaluator runs it client-side, so the bind value `:application` is already trimmed and upper-cased - no `TRIM`/`UPPER` appears in SQL.
- `FirstOrDefault` -> Oracle10 `ROWNUM <= 1` wrapper.

## Operations and processes
- OnlineMessagesApiService.ValidateApplicationCode — see [Operations and processes](../operations-processes.md)

## Sources
- `Services/SAIF.Services/OnlineMessages/OnlineMessagesApiService.cs (L123)`
