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

# SQL-159: Retrieve DocumentImagingError

This statement reads `DocumentImagingError` rows via NHibernate LINQ over `IUnitOfWork.GetRepository<T>()`. `ExportErrorEnrollmentDocuments` loads the full error table, and `InsertErrorImage` reads the document-handle column to check for an existing image before inserting a new one.

## Classification

| Field | Value |
| --- | --- |
| **SQL ID** | SQL-159 |
| **Operation type** | Read |
| **Execution method** | ORM (NHibernate LINQ) |
| **Database** | Oracle |
| **Schema** | CLM_DBA |
| **Command type** | N/A (ORM-generated) |
| **Business object** | `DocumentImagingError` |
| **Criteria property** | N/A — ORM |
| **Lifecycle method** | `ExportErrorEnrollmentDocuments, InsertErrorImage` |

## Parameters

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| (none) | N/A | N/A | N/A | Both statements are unfiltered full-table reads |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [DOCUMENT_IMAGING_ERROR](../database-tables.md#document_imaging_error) | Read | (1) all mapped columns (ID, PDF_ID, CLAIM_NUMBER, DOC_TYPE, DOC_SUB_TYPE, ERROR_DESCRIPTION, PROCESSING_DATE, DOCUMENT_HANDLE, CREATE_DATE); (2) DOCUMENT_HANDLE |

## LINQ statement

Source: `Services/SAIF.Services/Imaging/McoImageExporter.cs:153`. Additional fragment at `:297`.

```csharp
// Services/SAIF.Services/Imaging/McoImageExporter.cs:153
tableErrors = repository.Query().ToList();

// Services/SAIF.Services/Imaging/McoImageExporter.cs:297
var existingDocHandles = repository.Query().Select(e => e.DocHandle).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
-- (1) McoImageExporter.cs:153 — ExportErrorEnrollmentDocuments: repository.Query().ToList()
SELECT DIE.ID,
       DIE.PDF_ID,
       DIE.CLAIM_NUMBER,
       DIE.DOC_TYPE,
       DIE.DOC_SUB_TYPE,
       DIE.ERROR_DESCRIPTION,
       DIE.PROCESSING_DATE,
       DIE.DOCUMENT_HANDLE,
       DIE.CREATE_DATE
FROM   CLM_DBA.document_imaging_error DIE;

-- (2) McoImageExporter.cs:297 — InsertErrorImage: Select(e => e.DocHandle).ToList()
SELECT DIE.DOCUMENT_HANDLE
FROM   CLM_DBA.document_imaging_error DIE;
```

Translation notes:
- Mapping declares `Schema("CLM_DBA")`, so the table is schema-qualified.
- (2) is a scalar projection; the `IsIn` duplicate check at L298 runs in memory over the returned list.
- The per-row `_imagingClient.GetImageByDocHandle` calls at L157 are service calls, not SQL.

## Operations and processes
- McoImageExporter.ExportErrorEnrollmentDocuments — see [Operations and processes](../operations-processes.md)
- McoImageExporter.InsertErrorImage — see [Operations and processes](../operations-processes.md)

## Sources
- `Services/SAIF.Services/Imaging/McoImageExporter.cs (L153, L297)`
