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

# SQL-103: Retrieve BillStatus via SaveLegalBill

This ORM statement performs a read operation on `BillStatus` via `IUnitOfWork.GetRepository<T>()`, executed from `Services/SAIF.Services/Legal/Bills/BillSaveService.cs (L350, L368)`.

## Classification

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

## Parameters

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| `bill.BillStatus.Code` | Input | ** | N/A | `x.Code == bill.BillStatus.Code` → column CODE |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [BILL_STATUS_CODE](../database-tables.md#bill_status_code) | SELECT | `CODE`, `CODE_DESCR`, `FILTER_GROUPING_TEXT` |

## LINQ statement

Source: `Services/SAIF.Services/Legal/Bills/BillSaveService.cs:349`

```csharp
// Services/SAIF.Services/Legal/Bills/BillSaveService.cs:349-352
                legalBill.BillStatus =
                       _unitOfWork.GetRepository<BillData.BillStatus>()
                           .Query()
                           .SingleOrDefault(x => x.Code == bill.BillStatus.Code);

// Services/SAIF.Services/Legal/Bills/BillSaveService.cs:367-370
                    legalBill.BillStatus =
                              _unitOfWork.GetRepository<BillData.BillStatus>()
                             .Query()
                              .SingleOrDefault(x => x.Code == bill.BillStatus.Code);
```

## 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/Legal/Bills/BillSaveService.cs:350
SELECT
  BSC.CODE,
  BSC.CODE_DESCR,
  BSC.FILTER_GROUPING_TEXT
FROM BILL_STATUS_CODE BSC
WHERE BSC.CODE = :Code
-- NHibernate expects at most one row

-- Services/SAIF.Services/Legal/Bills/BillSaveService.cs:368
SELECT
  BSC.CODE,
  BSC.CODE_DESCR,
  BSC.FILTER_GROUPING_TEXT
FROM BILL_STATUS_CODE BSC
WHERE BSC.CODE = :Code
-- NHibernate expects at most one row
```

Translation notes:
- `bill.BillStatus.Code` is a member of the in-memory contract object -> bind `:Code` (evaluated client-side).

## Operations and processes
- BillSaveService.SaveLegalBill — see [Operations and processes](../operations-processes.md)

## Sources
- `Services/SAIF.Services/Legal/Bills/BillSaveService.cs (L350, L368)`
