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

# SQL-253: PolicyOutputDocumentExtensions.AddDocument

This statement is a create operation invoked through ORM (IRepository.Add). Executed by `PolicyOutputDocumentExtensions.AddDocument`.

## Classification

| Field | Value |
| --- | --- |
| **SQL ID** | SQL-253 |
| **Operation type** | Create |
| **Execution method** | ORM (IRepository.Add) |
| **Database** | Oracle* |
| **Schema** | [unqualified]** |
| **Command type** | N/A (ORM-generated) |
| **Business object** | `PolicyOutputDocumentExtensions` |
| **Criteria property** | N/A — ORM |
| **Lifecycle method** | `AddDocument` |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [policy_output_document](../database-tables.md#policy_output_document) | INSERT (hypothetical) | output_document_seq_num, update_num, policy_period_eff_date, agency_seq_num, agent_num, agency_viewed_flag, agency_delivery_flag, agency_delete_date, create_user, create_date, update_user, update_date, release_date, hold_task_seq_num, task_user, source_key_text, ACCOUNT_NUM, policy_num, document_status_code |

## LINQ statement

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

```csharp
// Data/SAIF.Data/TestRepository/RepositoryExtensions/PolicyOutputDocumentExtensions.cs:1723-1725
var poRepo = uow.GetRepository<PolicyOutputDocument>();
oRepo.Add(doc);
poRepo.Add(doc.PolicyOutputDocument);
```

## 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
INSERT INTO policy_output_document (
  output_document_seq_num,
  update_num,
  policy_period_eff_date,
  agency_seq_num,
  agent_num,
  agency_viewed_flag,
  agency_delivery_flag,
  agency_delete_date,
  create_user,
  create_date,
  update_user,
  update_date,
  release_date,
  hold_task_seq_num,
  task_user,
  source_key_text,
  ACCOUNT_NUM,
  policy_num,
  document_status_code)
VALUES (
  :Id,
  :UpdateNumber,
  :PolicyPeriodEffectiveDate,
  :AgencyId,
  :AgentId,
  :AgencyViewed,
  :AgencyDelivery,
  :AgencyDeleteDate,
  :CreateUser,
  :CreateDate,
  :UpdateUser,
  :UpdateDate,
  :ReleaseDate,
  :HoldTaskId,
  :TaskUser,
  :SourceKeyText,
  :AccountNumber,
  :Policy,
  :DocumentStatus)
```

Translation notes:
- Not accessed: `POLICY`, `document_status_code` — `References(Policy)`/`References(DocumentStatus)` contribute FK values only.
- `Id(...).GeneratedBy.Foreign("OutputDocument")` — the key `output_document_seq_num` is copied from the parent `OutputDocument` (SQL-252) so the INSERT follows the parent INSERT.

## Sources

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