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

# SQL-050: BillQueryProvider.GetIcdVersion

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

## Classification

| Field | Value |
| --- | --- |
| **SQL ID** | SQL-050 |
| **Operation type** | Read |
| **Execution method** | ORM (NHibernate LINQ) |
| **Database** | Unknown** |
| **Schema** | Unknown** |
| **Command type** | N/A (ORM-generated) |
| **Business object** | `BillQueryProvider` |
| **Criteria property** | N/A — ORM |
| **Lifecycle method** | `GetIcdVersion` |

## Parameters

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

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [IcdVersionCode](../database-tables.md#icdversioncode) ** | SELECT | Code (unresolved); probable physical table `ICD_VERSION_CODE` per the uncompiled source map |

## LINQ statement

Source: `Data/SAIF.Data/Queries/Claims/BillQueryProvider.cs:228`.

```csharp
return Factory.GetRepository<IcdVersionCode>().Query().SingleOrDefault(x => x.Code == icdVersion);
```

## 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
  IVC.*  -- unresolved mapping: IcdVersionCode (entity columns)
FROM IcdVersionCode IVC  -- unresolved mapping: IcdVersionCode
WHERE IVC.Code = :icdVersion  -- unresolved mapping: IcdVersionCode.Code
-- NHibernate expects at most one row
```

Translation notes:
- **Unresolved mapping.** The entity `SAIF.Data.Model.Claims.Ebilling.IcdVersionCode` (resolved via `using SAIF.Data.Model.Claims.Ebilling;` at `BillQueryProvider.cs:7`) has no compiled NHibernate mapping: both in-repo candidates — `Mappings/Claims/Ebilling/IcdCodeVersionMap.cs` and `Mappings/Claims/CodeTableMaps/IcdCodeVersionMap.cs` — are absent from the `<Compile Include>` list in `Data/SAIF.Data.NHibernate/SAIF.Data.NHibernate.csproj`, so neither is part of the runtime mapping assembly.
- A Legends CLI query against `SAIF.Framework.Data.NHibernate` confirmed the framework does not supply a `ClassMap` for `IcdVersionCode` either; its 42 maps cover unrelated areas (Contacts, Deployment, Employee, Imaging, Menu, PDF, Preferences, Printing, Users, WebContext).
- The uncompiled source map's declared shape (`Table("ICD_VERSION_CODE")`, `Id(Code)`, `Version UPDATE_NUM`, `Map` columns `CODE_DESCR`, `EFF_DATE`, `EXP_DATE`, `UPDATE_USER`, `UPDATE_DATE`) is recorded as non-authoritative evidence only, per the skill's "never invent a table or column name" rule; it is not used to fabricate a concrete inferred statement.
- **Runtime risk:** querying an unmapped entity causes NHibernate to fail with a `QuerySyntaxException`/`MappingException` ("IcdVersionCode is not mapped"), unless a mapping is supplied by an assembly outside this repository.

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