---
title: "SQL-022: Create DocumentNotification via CreateEmailNotification"
summary: Create operation against DocumentNotification via NHibernate ORM.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-09-24
library: SAIF.Services
reference_type: package
---

# SQL-022: Create DocumentNotification via CreateEmailNotification

This ORM statement performs a create operation on `DocumentNotification` via `CreateEmailNotification`, executed from `Services/SAIF.Services/Agencies/AgencyService.cs` (L233).

## Classification

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

## Parameters

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| `:Id` | Input | `long` | N/A | Identifier from `EXT_USER_DOC_NOTIFY_SEQ.NEXTVAL` |
| `:ExtUserSeqNumber` | Input | `long` | N/A |  |
| `:AgencyId` | Input | `long` | N/A |  |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [EXT_USER_DOC_NOTIFY](../database-tables.md#ext_user_doc_notify) | INSERT | EXT_USER_DOC_NOTIFY_SEQ, EXT_USER_TYPE_SEQ_NUM, AGENCY_SEQ_NUM (identifier from sequence `EXT_USER_DOC_NOTIFY_SEQ.NEXTVAL`) |

## LINQ statement

Source: `Services/SAIF.Services/Agencies/AgencyService.cs:233`.

```csharp
// Services/SAIF.Services/Agencies/AgencyService.cs:493
private IRepository<agenciesDataModel.DocumentNotification> DocumentRepository
{
    get { return unitOfWork.GetRepository<agenciesDataModel.DocumentNotification>(); }
}

// Services/SAIF.Services/Agencies/AgencyService.cs:232
var notificationRepo = DocumentRepository;

// Services/SAIF.Services/Agencies/AgencyService.cs:233
notificationRepo.Add(documentNotification);
```

## 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 EXT_USER_DOC_NOTIFY_SEQ.NEXTVAL
FROM DUAL

INSERT INTO EXT_USER_DOC_NOTIFY (
  EXT_USER_DOC_NOTIFY_SEQ,
  EXT_USER_TYPE_SEQ_NUM,
  AGENCY_SEQ_NUM)
VALUES (
  :Id,
  :ExtUserSeqNumber,
  :AgencyId)
```

Translation notes:
- `:Id` is the value fetched from sequence `EXT_USER_DOC_NOTIFY_SEQ` (`GeneratedBy.Native("EXT_USER_DOC_NOTIFY_SEQ")`) before the INSERT; NHibernate assigns it to `DocumentNotification.Id`.

## Operations and processes
- AgencyService.CreateEmailNotification — see [Operations and processes](../operations-processes.md)

> **Note:** Statements marked with `**` could not be confirmed; treat as unknown until verified.

## Sources
- `Services/SAIF.Services/Agencies/AgencyService.cs (L233)`
