---
title: "SQL-161: LegalQueryProvider.GetAttorneyProfile"
summary: Read operation for `LegalQueryProvider.GetAttorneyProfile`
status: draft
owner: SAIF.Core documentation team
last_reviewed: 2026-09-24
library: SAIF.Data
reference_type: package
---

# SQL-161: LegalQueryProvider.GetAttorneyProfile

This statement is a read operation invoked through ORM (NHibernate LINQ). Executed by `LegalQueryProvider.GetAttorneyProfile`.

## Classification

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

## Parameters

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| `attorneyEmployeeId` | Input | string | N/A | Method argument of `LegalQueryProvider.GetAttorneyProfile` bound into the ORM expression; NHibernate generates the bind variable at runtime |

## 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: `Data/SAIF.Data/Queries/Legal/LegalQueryProvider.cs:113`.

```csharp
public AttorneyProfile GetAttorneyProfile(string attorneyEmployeeId)
{
    return Factory.GetRepository<AttorneyProfile>().Query().FirstOrDefault(x => x.AttorneyEmployeeId == attorneyEmployeeId);
}
```

## 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
    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 = :attorneyEmployeeId
) WHERE ROWNUM <= 1
```

Translation notes:
- `AttorneyEmployeeId` is the Id (`Id(x => x.AttorneyEmployeeId).Column("PROFILE_EMPLID")`).
- `References(x => x.AttorneyEmployee)` reuses `PROFILE_EMPLID`, so the column is selected once. The external `Employee` it points at is lazy and not queried here.

## Operations and processes

- [Legal case queries](../operations/legal-case-queries.md)

## Business rules

- [SD-BR-060 Case-to-claim resolution precedence](../business-rules.md#sd-br-060-case-to-claim-resolution-precedence)
- [SD-BR-061 Preferred employee name takes precedence](../business-rules.md#sd-br-061-preferred-employee-name-takes-precedence)

## Sources
- `Data/SAIF.Data/Queries/Legal/LegalQueryProvider.cs:113`
