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

# SQL-155: LegalQueryProvider.GetCaseCost

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

## Classification

| Field | Value |
| --- | --- |
| **SQL ID** | SQL-155 |
| **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** | `GetCaseCost` |

## Parameters

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

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [CASE_COST](../database-tables.md#case_cost) | SELECT | CASE_COST_SEQ_NUM, PREPAYMENT_FLAG, AUTHORIZER_EMPLID, AUTHORIZED_DATE, SERVICE_FROM_DATE, SERVICE_TO_DATE, AMOUNT_BILLED, AMOUNT_PAID, HOURS_BILLED, CREATE_USER, CREATE_DATE, UPDATE_USER, UPDATE_DATE, LEGAL_CASE_SEQ_NUM, PAYEE_FIRM_PROV_LOC_ID, PAYEE_PERSON_PROV_LOC_ID, SERVICE_CODE |

## LINQ statement

Source: `Data/SAIF.Data/Queries/Legal/LegalQueryProvider.cs:68`.

```csharp
public IEnumerable<CaseCost> GetCaseCost(long caseId)
{
    return Factory.GetRepository<CaseCost>().Query().Where(x => x.LegalCase.Id == caseId);
}
```

## 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
  CC.CASE_COST_SEQ_NUM,
  CC.PREPAYMENT_FLAG,
  CC.AUTHORIZER_EMPLID,
  CC.AUTHORIZED_DATE,
  CC.SERVICE_FROM_DATE,
  CC.SERVICE_TO_DATE,
  CC.AMOUNT_BILLED,
  CC.AMOUNT_PAID,
  CC.HOURS_BILLED,
  CC.CREATE_USER,
  CC.CREATE_DATE,
  CC.UPDATE_USER,
  CC.UPDATE_DATE,
  CC.LEGAL_CASE_SEQ_NUM,
  CC.PAYEE_FIRM_PROV_LOC_ID,
  CC.PAYEE_PERSON_PROV_LOC_ID,
  CC.SERVICE_CODE
FROM CASE_COST CC
WHERE CC.LEGAL_CASE_SEQ_NUM = :caseId
```

Translation notes:
- The method returns a deferred `IQueryable` typed as `IEnumerable<CaseCost>`. SQL runs when the caller enumerates it, and any operators the caller adds are appended to this statement.
- `x.LegalCase.Id` → `CC.LEGAL_CASE_SEQ_NUM` (`References(x => x.LegalCase).Column("LEGAL_CASE_SEQ_NUM")` in `CaseCostMap.cs`). No join.
- `PREPAYMENT_FLAG` is a YesNo column; it is selected, not filtered.

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