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

# SQL-212: ProviderQueryProvider.GetWorkingProviderRelationshipsByParentLocation

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

## Classification

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

## Parameters

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| `providerLocationId` | Input | long | N/A | Method argument of `ProviderQueryProvider.GetWorkingProviderRelationshipsByParentLocation` bound into the ORM expression; NHibernate generates the bind variable at runtime |
| `includeExpired` | Input | bool | N/A | Method argument of `ProviderQueryProvider.GetWorkingProviderRelationshipsByParentLocation` bound into the ORM expression; NHibernate generates the bind variable at runtime |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [PROVIDER_RELATIONSHIP](../database-tables.md#provider_relationship) | SELECT | PROVIDER_LOCATION_SEQ_NUM, PARENT_PROVIDER_LOC_SEQ_NUM, EFF_DATE, UPDATE_NUM, EXP_DATE, UPDATE_DATE, UPDATE_USER, PROVIDER_RELATIONSHIP_CODE |

## LINQ statement

Source: `Data/SAIF.Data/Queries/Providers/ProviderQueryProvider.cs:185-190`.

```csharp
//WRK
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed")]
public IEnumerable<ProviderRelationship> GetWorkingProviderRelationshipsByParentLocation(long providerLocationId,
    DateTime serviceDate, bool includeExpired = false)
{
    return Factory.GetRepository<ProviderRelationship>().Query()
        .Where(r =>
            r.Relationship.Code == WorkingRelationship &&
            r.ParentProviderLocation.Id == providerLocationId
               && (includeExpired || r.ExpirationDate == null)
          ).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
  PR.PROVIDER_LOCATION_SEQ_NUM,
  PR.PARENT_PROVIDER_LOC_SEQ_NUM,
  PR.EFF_DATE,
  PR.UPDATE_NUM,
  PR.EXP_DATE,
  PR.UPDATE_DATE,
  PR.UPDATE_USER,
  PR.PROVIDER_RELATIONSHIP_CODE
FROM PROVIDER_RELATIONSHIP PR
WHERE PR.PROVIDER_RELATIONSHIP_CODE = 'WRK'
  AND PR.PARENT_PROVIDER_LOC_SEQ_NUM = :providerLocationId
  AND (:includeExpired = 1 OR PR.EXP_DATE IS NULL)
```

Translation notes:
- `WorkingRelationship` is the constant `"WRK"` (line 17).
- The `serviceDate` parameter is accepted but never used in the predicate.
- `EFF_DATE` is both a key property (line 16) and a plain `Map` (line 22); it is selected once.
- `includeExpired` is a captured bool; see SQL-207 for the constant-folding note.

## Operations and processes

- [Provider queries](../operations/provider-queries.md)

## Business rules

- [SD-BR-080 Provider identity relationship and address code sets](../business-rules.md#sd-br-080-provider-identity-relationship-and-address-code-sets)
- [SD-BR-082 Dismissed bills excluded from provider location ids](../business-rules.md#sd-br-082-dismissed-bills-excluded-from-provider-location-ids)
- [SD-BR-083 Provider in MCO only within date window](../business-rules.md#sd-br-083-provider-in-mco-only-within-date-window)

## Sources
- `Data/SAIF.Data/Queries/Providers/ProviderQueryProvider.cs:185`
