---
title: "SQL-232: Retrieve Location via SetWitnessRecipients"
summary: Load the Location for a subpoena recipient's policy-location ID, when set.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-09-24
library: SAIF.Services
reference_type: package
---

# SQL-232: Retrieve Location via SetWitnessRecipients

`SubpoenaSaveService.SetWitnessRecipients` loads `Location` by primary key from `recipient.PolicyLocationId`. It runs only when `recipient.PolicyLocationId > 0`. `PolicyLocation` is a namespace alias for `SAIF.Data.Model.Locations`, the same `Location` entity mapped by `LocationMap`.

## Classification

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

## Parameters

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| `:policyLocationId` | Input | long | N/A | `recipient.PolicyLocationId` |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [LOCATION](../database-tables.md#location) | SELECT | all 32 mapped columns; filter LOC_SEQ_NUM |

## LINQ statement

Source: `Services/SAIF.Services/Legal/Subpoenas/SubpoenaSaveService.cs:277`

```csharp
_unitOfWork.GetRepository<PolicyLocation.Location>()
    .Query()
    .SingleOrDefault(x => x.Id == recipient.PolicyLocationId);
```

## 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 L.LOC_SEQ_NUM,
       L.POLICY_NUM,
       L.BUS_SEQ_NUM,
       L.AGENT_NUM,
       L.PARENT_LOC_SEQ_NUM,
       L.LOC_EFF_DATE,
       L.LOC_EXP_DATE,
       L.LOCATION_CODE,
       L.LOCATION_NAME,
       L.LOC_ADDR1,
       L.LOC_ADDR2,
       L.LOC_CITY,
       L.LOC_COUNTRY,
       L.LOC_PHONE,
       L.LOC_PHONE_EXT,
       L.LOC_FAX,
       L.LOC_STATE,
       L.LOC_ZIP,
       L.LOC_ZIP4,
       L.SIC_CODE,
       L.PROVIDER_NUM,
       L.CREATE_USER,
       L.CREATE_DATE,
       L.UPDATE_USER,
       L.UPDATE_DATE,
       L.USPS_BARCODE,
       L.EMAIL_ADDR,
       L.EMPLOYEE_COUNT,
       L.LOC_ADDR3,
       L.PRIMARY_LOCATION_FLAG,
       L.CELL_PHONE,
       L.LOC_COUNTY
FROM   LOCATION L
WHERE  L.LOC_SEQ_NUM = :policyLocationId
-- NHibernate expects at most one row
```

Translation notes:
- `SingleOrDefault`/`Single` add no row limit; NHibernate throws if more than one row is returned.
- Runs only when `recipient.PolicyLocationId > 0` (L274).

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

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