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

# SQL-160: LegalQueryProvider.GetActiveLegalCases

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

## Classification

| Field | Value |
| --- | --- |
| **SQL ID** | SQL-160 |
| **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** | `GetActiveLegalCases` |

## Parameters

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

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [LEGAL_CASE](../database-tables.md#legal_case) | SELECT | LEGAL_CASE_SEQ_NUM, CLAIM_ID, WCB_NUM, DCBS_NUM, OALJ_NUM, OWCP_NUM, BRB_NUM, REQUEST_DATE, CLAIM_IMAGE_ALERTS_FLAG, CREATE_USER, CREATE_DATE, UPDATE_USER, UPDATE_DATE, MOST_RECENT_HEARING_SEQ_NUM, CASE_STATUS_CODE, WORKER_ATTY_PROV_LOC_ID, WORKER_ATTY_FIRM_PROV_LOC_ID |
| [CASE_STATUS_CODE](../database-tables.md#case_status_code) | JOIN | CODE (join key), ACTIVE_FLAG (filter) |

## LINQ statement

Source: `Data/SAIF.Data/Queries/Legal/LegalQueryProvider.cs:108`. The repository/queryable is initialised at `Data/SAIF.Data/Queries/Legal/LegalQueryProvider.cs:28`.

```csharp
// Data/SAIF.Data/Queries/Legal/LegalQueryProvider.cs:28
repository = Factory.GetRepository<LegalCase>().Query();

// Data/SAIF.Data/Queries/Legal/LegalQueryProvider.cs:108
public IEnumerable<LegalCase> GetActiveLegalCases(long claimId)
{
    return repository.Where(x => x.ClaimId == claimId && x.Status.IsActive).ToList();
}
```

## 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
  LC.LEGAL_CASE_SEQ_NUM,
  LC.CLAIM_ID,
  LC.WCB_NUM,
  LC.DCBS_NUM,
  LC.OALJ_NUM,
  LC.OWCP_NUM,
  LC.BRB_NUM,
  LC.REQUEST_DATE,
  LC.CLAIM_IMAGE_ALERTS_FLAG,
  LC.CREATE_USER,
  LC.CREATE_DATE,
  LC.UPDATE_USER,
  LC.UPDATE_DATE,
  LC.MOST_RECENT_HEARING_SEQ_NUM,
  LC.CASE_STATUS_CODE,
  LC.WORKER_ATTY_PROV_LOC_ID,
  LC.WORKER_ATTY_FIRM_PROV_LOC_ID
FROM LEGAL_CASE LC
INNER JOIN CASE_STATUS_CODE CSC ON CSC.CODE = LC.CASE_STATUS_CODE
WHERE LC.CLAIM_ID = :claimId
  AND CSC.ACTIVE_FLAG = 'Y'
```

Translation notes:
- `repository` is `Factory.GetRepository<LegalCase>().Query()` (constructor, line 28).
- `Status.IsActive` → `ACTIVE_FLAG` mapped `CustomType<YesNoType>()` → `'Y'`.
- Implicit member-access navigation produces an INNER JOIN, NHibernate's default for property paths in a WHERE clause.

## 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:108`
