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

# SQL-291: PolicyOutputDocumentExtensions.SeedForDocumentTesting

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

## Classification

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

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [image_category_code](../database-tables.md#image_category_code) ** | SELECT ×3 (hypothetical) | image_file_code, code; other columns -- unresolved mapping |
| [image_document_type_code](../database-tables.md#image_document_type_code) ** | INSERT ×3 (hypothetical) | KeyReference(Category) columns (image_file_code, image_category_code — inferred), code; other columns -- unresolved mapping |

## LINQ statement

Source: `Data/SAIF.Data/TestRepository/RepositoryExtensions/PolicyOutputDocumentExtensions.cs:77`.

```csharp
// Data/SAIF.Data/TestRepository/RepositoryExtensions/PolicyOutputDocumentExtensions.cs:77
uow.GetRepository<ImageDocumentTypeCode>().Seed(uow.GetRepository<ImageCategoryCode>());

// Data/SAIF.Data/TestRepository/RepositoryExtensions/PolicyOutputDocumentExtensions.cs:114-130
public static void Seed(this IRepository<ImageDocumentTypeCode> repo, IRepository<ImageCategoryCode> imageCategoryRepo)
{
    var coverageImageCategory = imageCategoryRepo.Query().Single(x => x.FileCode == "POLCY" && x.Code == "C");
    var coverageImageType1 = new ImageDocumentTypeCode { Category = coverageImageCategory, Code = "C" };
    coverageImageCategory.Types = new List<ImageDocumentTypeCode> { coverageImageType1 };
    repo.Add(coverageImageType1);

    var polImageCategory = imageCategoryRepo.Query().Single(x => x.FileCode == "POLCY" && x.Code == "P");
    var polImageType1 = new ImageDocumentTypeCode { Category = polImageCategory, Code = "P" };
    polImageCategory.Types = new List<ImageDocumentTypeCode> { polImageType1 };
    repo.Add(polImageType1);

    var financialImageCategory = imageCategoryRepo.Query().Single(x => x.FileCode == "POLCY" && x.Code == "F");
    var financialImageType1 = new ImageDocumentTypeCode { Category = financialImageCategory, Code = "F" };
    financialImageCategory.Types = new List<ImageDocumentTypeCode> { financialImageType1 };
    repo.Add(financialImageType1);
}
```

## Sample SQL

> **Test double — no runtime SQL.** This statement executes against `TestUnitOfWork`/`TestRepository<T>` (in-memory, `List<TEntity>`-backed test doubles in `SAIF.Framework.Core`); no NHibernate session is opened and no SQL is issued at runtime. The SQL below is the hypothetical statement the same expression would produce against a real NHibernate `IUnitOfWork` using the in-repo mappings, shown to document the mapping shape only — **no database table is accessed when this code runs.**

> **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
-- lines 116/121/126: imageCategoryRepo.Query().Single(x => x.FileCode == "POLCY" && x.Code == <C|P|F>)
SELECT
  ICC.image_file_code,
  ICC.code
  -- unresolved mapping: remaining ImageCategoryCode columns
FROM image_category_code ICC
WHERE ICC.image_file_code = :p0  -- 'POLCY'
  AND ICC.code = :p1  -- 'C' | 'P' | 'F'
-- Single

-- lines 119/124/129: repo.Add(new ImageDocumentTypeCode { Category = ..., Code = ... })
INSERT INTO image_document_type_code (
  image_file_code,      -- KeyReference(Category) part 1 (column name inferred)
  image_category_code,  -- KeyReference(Category) part 2 (column name inferred)
  code
  -- unresolved mapping: remaining ImageDocumentTypeCode columns
)
VALUES (
  :Category_FileCode,
  :Category_Code,
  :Code)
```

Translation notes:
- **Unresolved mapping (partial):** both entities are mapped only in the external SAIF.Framework.Data.NHibernate package; Legends L3 resolves tables and keys, L4 found no column lists. KeyReference column names are inferred from `output_document_type_code`'s 3-column FK (`image_file_code`, `image_category_code`, `image_document_type_code`, `OutputDocumentTypeCodeBaseMap.cs`).
- `coverageImageCategory.Types = new List<...>` mutates an inverse/unknown collection mapping — effect on flush cannot be determined without the external map.

## Sources

- `Data/SAIF.Data/TestRepository/RepositoryExtensions/PolicyOutputDocumentExtensions.cs:77`
