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

# SQL-064: ClaimQueryProvider.GetClaimLegalRepresentative

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

## Classification

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

## Parameters

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| `claimId` | Input | long | N/A | Method argument of `ClaimQueryProvider.GetClaimLegalRepresentative` bound into the ORM expression; NHibernate generates the bind variable at runtime |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [CL_CLAIM_LEGAL_REPRESENTATIVE](../database-tables.md#cl_claim_legal_representative) | SELECT (outer query and scalar subquery) | CLAIM_ID, EFF_DATE, UPDATE_NUM, EXP_DATE, UPDATE_DATE, UPDATE_USER, LEGAL_REP_END_REASON_CODE, PROVIDER_LOCATION_SEQ_NUM, PARENT_PROVIDER_LOC_SEQ_NUM |

## LINQ statement

Source: `Data/SAIF.Data/Queries/Claims/ClaimQueryProvider.cs:303-307`.

```csharp
// Data/SAIF.Data/Queries/Claims/ClaimQueryProvider.cs:303
var repo = Factory.GetRepository<ClaimLegalRepresentative>();
return repo.Query().Where(x => x.ClaimId == claimId)
           .SingleOrDefault(x => x.EffectiveDate == repo.Query()
                                             .Where(w => w.ClaimId == claimId)
                                             .Max(m => m.EffectiveDate));
```

## 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
  CCLR.CLAIM_ID,
  CCLR.EFF_DATE,
  CCLR.UPDATE_NUM,
  CCLR.EXP_DATE,
  CCLR.UPDATE_DATE,
  CCLR.UPDATE_USER,
  CCLR.LEGAL_REP_END_REASON_CODE,
  CCLR.PROVIDER_LOCATION_SEQ_NUM,
  CCLR.PARENT_PROVIDER_LOC_SEQ_NUM
FROM CL_CLAIM_LEGAL_REPRESENTATIVE CCLR
WHERE CCLR.CLAIM_ID = :claimId
  AND CCLR.EFF_DATE = (
    SELECT MAX(CCLR2.EFF_DATE)
    FROM CL_CLAIM_LEGAL_REPRESENTATIVE CCLR2
    WHERE CCLR2.CLAIM_ID = :claimId
  )
-- NHibernate expects at most one row
```

Translation notes:
- (`CLAIM_ID`, `EFF_DATE`) is the composite key, so at most one row matches.
- The `Provider`, `ParentProvider` and `LegalRepresentativeEndReason` references are not navigated; only their FK columns are selected, so those tables are not accessed as separate joins.

## Operations and processes

- [Claim status and compensability](../operations/claim-status-and-compensability.md)


## Sources
- `Data/SAIF.Data/Queries/Claims/ClaimQueryProvider.cs:303`
