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

# SQL-237: WorkerQueryProvider.GetActiveSupportOrderCount

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

## Classification

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

## Parameters

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

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [CL_CLAIM_SUPPORT_ORDER](../database-tables.md#cl_claim_support_order) | SELECT (COUNT) | TERM_DATE, WORKER_ID |

## LINQ statement

Source: `Data/SAIF.Data/Queries/Claims/WorkerQueryProvider.cs:30`.

```csharp
// Data/SAIF.Data/Queries/Claims/WorkerQueryProvider.cs:30-31
return Factory.GetRepository<SupportOrder>().Query()
    .Count(x => !x.TerminationDate.HasValue && x.Worker.PersonId == workerId);
```

## 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 COUNT(*)
FROM CL_CLAIM_SUPPORT_ORDER CCSO
WHERE CCSO.TERM_DATE IS NULL
  AND CCSO.WORKER_ID = :workerId
```

Translation notes:
- Not accessed: `CL_CLAIM_PERSON` — `x.Worker.PersonId` navigates to the **identifier** of `ClaimPerson`, so NHibernate short-circuits to the FK column `CL_CLAIM_SUPPORT_ORDER.WORKER_ID` (`References(x => x.Worker).Column("WORKER_ID")`); no join is issued.
- `!x.TerminationDate.HasValue` → `TERM_DATE IS NULL`.
- `Count(predicate)` is a terminal aggregate; no entity columns are selected.

## Operations and processes

- [Other query providers](../operations/other-query-providers.md)

## Business rules

- [SD-BR-092 Active support order has no termination date](../business-rules.md#sd-br-092-active-support-order-has-no-termination-date)

## Sources

- `Data/SAIF.Data/Queries/Claims/WorkerQueryProvider.cs:30`
