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

# SQL-095: Retrieve BillService via SaveBillServices

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

## Classification

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

## Parameters

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

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [BILL_SERVICE_CODE](../database-tables.md#bill_service_code) | SELECT | `CODE`, `CODE_DESCR`, `GL_EXPENSE_ACCOUNT_NUM`, `SPEND_CATEGORY` |

## LINQ statement

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

```csharp
// Services/SAIF.Services/Legal/Bills/BillSaveService.cs:438-440
                billService.BillService = _unitOfWork.GetRepository<BillData.BillService>()
                    .Query()
                    .SingleOrDefault(x => x.Code == legalBillService.BillService.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:438
SELECT
  BSC.CODE,
  BSC.CODE_DESCR,
  BSC.GL_EXPENSE_ACCOUNT_NUM,
  BSC.SPEND_CATEGORY
FROM BILL_SERVICE_CODE BSC
WHERE BSC.CODE = :Code
-- NHibernate expects at most one row
```

Translation notes:
- `legalBillService.BillService.Code` is a captured in-memory object member -> bind `:Code`.

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

## Sources
- `Services/SAIF.Services/Legal/Bills/BillSaveService.cs (L438)`
