---
title: "SQL-204: Retrieve Image via GetDataImage"
summary: Read operation against Image via NHibernate ORM.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-09-24
library: SAIF.Services
reference_type: package
---

# SQL-204: Retrieve Image via GetDataImage

This statement loads a single `Image` record by its identifier so that `ImageService.GetDataImage` can return the stored image data. It is issued through NHibernate LINQ against the `Image` entity from `Services/SAIF.Services/Agencies/Imaging/ImageService.cs:219`. The `Image` entity's mapping lives in the external `SAIF.Framework.Data.NHibernate` package; Legends resolved the backing table (`image`) but not its column names (see the Tables section).

## Classification

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

## Parameters

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| `:id` | Input | long | N/A | `i.Id == id` |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [image](../database-tables.md#image)** | SELECT | Id (unresolved), all mapped columns (unresolved) |

## LINQ statement

Source: `Services/SAIF.Services/Agencies/Imaging/ImageService.cs:219`

```csharp
var image = unitOfWork.GetRepository<Data.Model.Imaging.Image>().Query().Single(i => i.Id == id);
```

## 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 I.* /* full ImageMap column list */      -- unresolved mapping: Image.*
FROM   image I
WHERE  I.Id = :id;                                -- unresolved mapping: Image.Id
-- NHibernate expects at most one row
```

Translation notes:
- `Image` (`Data.Model.Imaging.Image`) has no in-repo `ClassMap`; its mapping lives in the external `SAIF.Framework.Data.NHibernate` package. Legends resolved the table (`image`) but not the column names, so the columns above use the C# property names with `-- unresolved mapping:` comments, and the table is marked `**`.
- `Single` throws if no row.

## Operations and processes
- ImageService.GetDataImage — see [Operations and processes](../operations-processes.md)

## Sources
- `Services/SAIF.Services/Agencies/Imaging/ImageService.cs (L219)`
