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

# SQL-376: Delete DocumentTemplateOutputProfile via DeleteTemplateOutputProfiles

This statement deletes each `DocumentTemplateOutputProfile` entity in a set of detached copies produced for a given template, via `IUnitOfWork.GetRepository<T>().Delete(entity)` inside a `foreach` loop, invoked from `TemplateSearchService.DeleteTemplateOutputProfiles` (`Services/SAIF.Services/Documents/TemplateSearchService.cs:815`). One DELETE is issued per row (`DOCUMENT_TEMPLATE_OP_SEQ_NUM`). The SQL below is inferred from this repository call and the `DocumentTemplateOutputProfile` NHibernate mapping — it is not literal SQL present in source.

## Classification

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

## Parameters

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

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [DOCUMENT_TEMPLATE_OP](../database-tables.md#document_template_op) | DELETE | `DOCUMENT_TEMPLATE_OP_SEQ_NUM` |

## LINQ statement

Source: `Services/SAIF.Services/Documents/TemplateSearchService.cs:815`

```csharp
// Services/SAIF.Services/Documents/TemplateSearchService.cs:813
foreach (var result in results)
{
    unitOfWork.GetRepository<DocumentTemplateOutputProfile>().Delete(result);
```

## 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 DOCUMENT_TEMPLATE_OP
WHERE DOCUMENT_TEMPLATE_OP_SEQ_NUM = :Id
```

Translation notes:

- `results` are detached copies produced by `Mapper.Map<DocumentTemplateOutputProfile[]>(...)` (line 809); deleted by identifier.

## Operations and processes
- TemplateSearchService.DeleteTemplateOutputProfiles — see [Operations and processes](../operations-processes.md)

## Sources
- `Services/SAIF.Services/Documents/TemplateSearchService.cs (L815)`
