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

# SQL-292: Retrieve Recipient via SaveRecipients

This NHibernate LINQ query reads `SUBPOENA_RECIPIENT` filtered by recipient identifier and returns the first (only) match, wrapped by the Oracle10 row-limit form. `SubpoenaSaveService.SaveRecipients` uses the loaded recipient (or a new instance when none is found) as the target of subsequent updates.

## Classification

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

## Parameters

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| `:Id` | Input | long | N/A | `subpoenaRecipient.Id` |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [SUBPOENA_RECIPIENT](../database-tables.md#subpoena_recipient) | SELECT | `RECIPIENT_SEQ_NUM`, `UPDATE_NUM`, `MILEAGE_UNITS`, `MILEAGE_COST`, `AMOUNT_PAID`, `RETURNED_DATE`, `RECIPIENT_PAID_FLAG`, `CREATE_USER`, `CREATE_DATE`, `UPDATE_USER`, `UPDATE_DATE`, `SUBPOENA_SEQ_NUM`, `PROV_LOC_SEQ_NUM`, `REGISTERED_AGENT_LOC_SEQ_NUM`, `POLICY_LOC_SEQ_NUM`, `LEGAL_PERSON_SEQ_NUM` |

## LINQ statement

Source: `Services/SAIF.Services/Legal/Subpoenas/SubpoenaSaveService.cs:224-227`

```csharp
// Services/SAIF.Services/Legal/Subpoenas/SubpoenaSaveService.cs:224-227
var dataRecipient =
    _unitOfWork.GetRepository<SubpoenaData.Recipient>()
        .Query()
        .FirstOrDefault(x => x.Id == subpoenaRecipient.Id) ?? new SubpoenaData.Recipient();
```

## 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 *
FROM (
  SELECT
    SR.RECIPIENT_SEQ_NUM,
    SR.UPDATE_NUM,
    SR.MILEAGE_UNITS,
    SR.MILEAGE_COST,
    SR.AMOUNT_PAID,
    SR.RETURNED_DATE,
    SR.RECIPIENT_PAID_FLAG,
    SR.CREATE_USER,
    SR.CREATE_DATE,
    SR.UPDATE_USER,
    SR.UPDATE_DATE,
    SR.SUBPOENA_SEQ_NUM,
    SR.PROV_LOC_SEQ_NUM,
    SR.REGISTERED_AGENT_LOC_SEQ_NUM,
    SR.POLICY_LOC_SEQ_NUM,
    SR.LEGAL_PERSON_SEQ_NUM
  FROM SUBPOENA_RECIPIENT SR
  WHERE SR.RECIPIENT_SEQ_NUM = :Id
)
WHERE ROWNUM <= 1
```

Translation notes:
- Executes once per recipient in the `foreach` (L221); `?? new Recipient()` is in memory.
- `First`/`FirstOrDefault` → Oracle10 dialect row limit `SELECT * FROM (...) WHERE ROWNUM <= 1`.

## Operations and processes
- SubpoenaSaveService.SaveRecipients — see [Operations and processes](../operations-processes.md)

## Sources
- `Services/SAIF.Services/Legal/Subpoenas/SubpoenaSaveService.cs (L225)`
