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

# SQL-303: Retrieve StatusCode via GetStatusCodes

This statement retrieves every `StatusCode` row ordered by description via a full-table NHibernate LINQ query, executed from `Services/SAIF.Services/Collections/CollectionsService.cs (L1113)` and materialized with `.ToList()`. It backs `GetStatusCodes`, which supplies the complete list of legal collection status codes for collections processing.

## Classification

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

## Parameters

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| (none) | N/A | N/A | N/A | Full-table read — no filter predicate |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [LEGAL_COLLECTION_STATUS_CODE](../database-tables.md#legal_collection_status_code) | SELECT | `Code`, `CODE_DESCR` |

## LINQ statement

Source: `Services/SAIF.Services/Collections/CollectionsService.cs:1113`

```csharp
// Services/SAIF.Services/Collections/CollectionsService.cs:1113-1114
return Mapper.Map<StatusCode[]>(UnitOfWork.GetRepository<DataModel.StatusCode>()
    .Query().OrderBy(x => x.Description).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
  LCSC.Code,
  LCSC.CODE_DESCR
FROM LEGAL_COLLECTION_STATUS_CODE LCSC
ORDER BY LCSC.CODE_DESCR
```

Translation notes:
- `Id(x => x.Code)` (`StatusCodeMap.cs:12`) has no `.Column(...)`, so NHibernate uses the property name `Code` as the column name (Oracle resolves unquoted identifiers case-insensitively, so this matches a `CODE` column).
- `Mappings/Collections/CollectionsMap.cs` also declares a `StatusCodeMap` but is not compiled (no `Compile` entry in `SAIF.Data.NHibernate.csproj`; `StatusCodeMap.cs` is compiled at csproj L468).
- Full-table read; `.ToList()` materializes.

## Operations and processes
- CollectionsService.GetStatusCodes — see [Operations and processes](../operations-processes.md)

## Sources
- `Services/SAIF.Services/Collections/CollectionsService.cs (L1113)`
