---
title: "SQL-259: ClaimBuilder.ClaimStatus"
summary: Read operation for `ClaimBuilder.ClaimStatus`
status: draft
owner: SAIF.Core documentation team
last_reviewed: 2026-09-24
library: SAIF.Data
reference_type: package
---

# SQL-259: ClaimBuilder.ClaimStatus

This statement is a read operation invoked through ORM (NHibernate LINQ). Executed by `ClaimBuilder.ClaimStatus`.

## Classification

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

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [CL_CLAIM_STATUS_ACTIVITY](../database-tables.md#cl_claim_status_activity) | SELECT (existence, MAX) (hypothetical) | CLAIM_STATUS_ACTIVITY_SEQ_NUM |

## LINQ statement

Source: `Data/SAIF.Data/TestRepository/RepositoryBuilders/ClaimBuilder.cs:62`.

```csharp
// Data/SAIF.Data/TestRepository/RepositoryBuilders/ClaimBuilder.cs:62-63
var repo = Uow.GetRepository<ClaimStatusActivity>();
var subId = repo.Query().Any() ? repo.Query().Max(x => x.SubId) + 1 : 1;
```

## Sample SQL

> **Test double — no runtime SQL.** This statement executes against `TestUnitOfWork`/`TestRepository<T>` (in-memory, `List<TEntity>`-backed test doubles in `SAIF.Framework.Core`); no NHibernate session is opened and no SQL is issued at runtime. The SQL below is the hypothetical statement the same expression would produce against a real NHibernate `IUnitOfWork` using the in-repo mappings, shown to document the mapping shape only — **no database table is accessed when this code runs.**

> **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
-- repo.Query().Any()
SELECT *
FROM (
  SELECT 1
  FROM CL_CLAIM_STATUS_ACTIVITY CCSA)
WHERE ROWNUM <= 1

-- repo.Query().Max(x => x.SubId)  (only when Any() is true)
SELECT MAX(CCSA.CLAIM_STATUS_ACTIVITY_SEQ_NUM)
FROM CL_CLAIM_STATUS_ACTIVITY CCSA
```

Translation notes:
- Scope split: see SQL-242 — this entry documents the reads at line 63.
- Neither query is filtered by `CLAIM_ID` — the max is table-wide (behaviour preserved from source).
- `SubId` is a `KeyProperty` of the composite id (`CLAIM_STATUS_ACTIVITY_SEQ_NUM`) in the compiled `ClaimStatusActvityMap.cs`.

## Sources

- `Data/SAIF.Data/TestRepository/RepositoryBuilders/ClaimBuilder.cs:62`
