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

# SQL-372: Delete DocumentNotification via DeleteEmailNotification

This statement deletes the `DocumentNotification` entity identified by its identifier (`EXT_USER_DOC_NOTIFY_SEQ`) via `IUnitOfWork.GetRepository<T>().Delete(entity)`, invoked from `AgencyService.DeleteEmailNotification` (`Services/SAIF.Services/Agencies/AgencyService.cs:263`). The entity is located by a query on `AgencyId`/`ExtUserSeqNumber` before the delete. The SQL below is inferred from this repository call and the `DocumentNotification` NHibernate mapping — it is not literal SQL present in source.

## Classification

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

## Parameters

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| `:Id` | Input | long | N/A | Identifier of the DocumentNotification being deleted (`EXT_USER_DOC_NOTIFY_SEQ`) |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [EXT_USER_DOC_NOTIFY](../database-tables.md#ext_user_doc_notify) | DELETE | `EXT_USER_DOC_NOTIFY_SEQ` |

## LINQ statement

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

```csharp
// Services/SAIF.Services/Agencies/AgencyService.cs:256
var notificationRepo = DocumentRepository;
var notification = DocumentNotificationQuery.FirstOrDefault(x => x.AgencyId == agencyId && x.ExtUserSeqNumber == userSeqNum);

// Services/SAIF.Services/Agencies/AgencyService.cs:263
notificationRepo.Delete(notification);
```

## 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
DELETE FROM EXT_USER_DOC_NOTIFY
WHERE EXT_USER_DOC_NOTIFY_SEQ = :Id
```

Translation notes:

- `notificationRepo` is the `DocumentRepository` property (`GetRepository<agenciesDataModel.DocumentNotification>()`, `AgencyService.cs:493-496`). The `FirstOrDefault` lookup at line 257 is a separate read.

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

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