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

# SQL-085: Retrieve AttorneyProfile via SetAttorneyInfo

This ORM statement performs a read operation on `AttorneyProfile` via `IUnitOfWork.GetRepository<T>()`, executed from `Services/SAIF.Services/Legal/Subpoenas/SubpoenaDocumentService.cs (L615)`.

## Classification

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

## Parameters

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| `subpoena.RequestedByEmployeeId` | Input | ** | N/A | `x.AttorneyEmployeeId == subpoena.RequestedByEmployeeId` → column PROFILE_EMPLID |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [ATTORNEY_PROFILE](../database-tables.md#attorney_profile) | SELECT | `PROFILE_EMPLID`, `SECRETARY_EMPLID`, `MANAGER_EMPLID`, `OREGON_STATE_BAR_NUMBER`, `EFF_DATE`, `EXP_DATE`, `CREATE_USER`, `CREATE_DATE`, `UPDATE_USER`, `UPDATE_DATE` |

## LINQ statement

Source: `Services/SAIF.Services/Legal/Subpoenas/SubpoenaDocumentService.cs:615`

```csharp
// Services/SAIF.Services/Legal/Subpoenas/SubpoenaDocumentService.cs:615-616
            var attorneyProfile = _unitOfWork.GetRepository<AttorneyProfile>().Query()
                .FirstOrDefault(x => x.AttorneyEmployeeId == subpoena.RequestedByEmployeeId);
```

## 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/Subpoenas/SubpoenaDocumentService.cs:615
SELECT *
FROM (
  SELECT
    AP.PROFILE_EMPLID,
    AP.SECRETARY_EMPLID,
    AP.MANAGER_EMPLID,
    AP.OREGON_STATE_BAR_NUMBER,
    AP.EFF_DATE,
    AP.EXP_DATE,
    AP.CREATE_USER,
    AP.CREATE_DATE,
    AP.UPDATE_USER,
    AP.UPDATE_DATE
  FROM ATTORNEY_PROFILE AP
  WHERE AP.PROFILE_EMPLID = :RequestedByEmployeeId
)
WHERE ROWNUM <= 1
```

Translation notes:
- `subpoena.RequestedByEmployeeId` is a member of a captured object -> bind `:RequestedByEmployeeId`.

## Operations and processes
- SubpoenaDocumentService.SetAttorneyInfo — see [Operations and processes](../operations-processes.md)

## Sources
- `Services/SAIF.Services/Legal/Subpoenas/SubpoenaDocumentService.cs (L615)`
