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

# SQL-027: BillQueryProvider.GetBillIdsForClaim

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

## Classification

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

## Parameters

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

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [CBP_BILL](../database-tables.md#cbp_bill)** | SELECT | BILL_ID; predicate column unresolved (`Claim`) |

## LINQ statement

Source: `Data/SAIF.Data/Queries/Claims/BillQueryProvider.cs:50`. The repository is a class field initialised from `Factory.GetRepository<CbpBill>().Query()` at `Data/SAIF.Data/Queries/Claims/BillQueryProvider.cs:26`.

```csharp
return repository.Where(x => x.Claim.Id == claimId).Select(x => x.Id).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
  CB.BILL_ID
FROM CBP_BILL CB
WHERE CB.Claim.Id = :claimId -- unresolved mapping: CbpBill.Claim
```

Translation notes:
- **Unresolved mapping `CbpBill.Claim`:** the same issue as SQL-026 — `CbpBillMap` has no `References(x => x.Claim)`, only `Map(x => x.ClaimId).Column("CLAIM_ID")`. This query is expected to fail at runtime with an NHibernate `QueryException`.
- **Likely intent:** if the mapping is fixed, this becomes `CB.CLAIM_ID = :claimId` with no join.
- `CL_INJURY_CLAIM` is not included, because no mapping links `CbpBill` to `InjuryClaim`.

## Operations and processes

- [Bill queries](../operations/bill-queries.md)

## Business rules

- [SD-BR-034 Bill entry source classification](../business-rules.md#sd-br-034-bill-entry-source-classification)
- [SD-BR-035 Bill allowed total treats null as zero](../business-rules.md#sd-br-035-bill-allowed-total-treats-null-as-zero)
- [SD-BR-036 Service code current only when expiration date is null](../business-rules.md#sd-br-036-service-code-current-only-when-expiration-date-is-null)

## Sources
- `Data/SAIF.Data/Queries/Claims/BillQueryProvider.cs:50`
