---
title: "SQL-033: AuditNote delete (CbpNote)"
summary: Removes the note's CbpNote entity from the repository, deleting the corresponding row.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-09-24
library: SAIF.Domain
reference_type: package
---

# SQL-033: AuditNote delete (CbpNote)

`AuditNote.Delete` removes the note's `CbpNote` entity from the repository, deleting the corresponding `CBP_NOTE` row.

## Classification

| Field | Value |
| --- | --- |
| **SQL ID** | SQL-033 |
| **Operation type** | Delete |
| **Execution method** | ORM (IRepository.Delete) |
| **Database** | Oracle* |
| **Schema** | [unqualified]** |
| **Command type** | N/A — ORM (NHibernate generates SQL at runtime from the ClassMaps in `Data/SAIF.Data.NHibernate/Mappings/**`) |
| **Business object** | `AuditNote` |
| **Criteria property** | N/A — ORM |
| **Lifecycle method** | `Delete` |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [CBP_NOTE](../database-tables.md#cbp_note) | DELETE | `CBP_NOTE_SEQ_NUM`, `UPDATE_NUM` |

## LINQ statement

Source: `Domain/SAIF.Domain/Model/Claims/Bills/Notes/AuditNote.cs:151`

```csharp
// Domain/SAIF.Domain/Model/Claims/Bills/Notes/AuditNote.cs:149-152
public void Delete()
{
    Factory.GetRepository<CbpNote>().Delete(DataItem);
}
```

## 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 CBP_NOTE
WHERE CBP_NOTE_SEQ_NUM = :Id
  AND UPDATE_NUM = :oldVersion
```

Translation notes:
- `RepositoryBase.Delete` → `ISession.Delete(entity)` (Legends: SAIF.Framework.Data.NHibernate RepositoryBase); the DELETE is emitted at flush.
- Version `UPDATE_NUM` with `OptimisticLock.Version()` (`CbpNoteMap.cs:17-20`) → `AND UPDATE_NUM = :oldVersion`.
- If the note is still in a loaded `CbpBill.Notes` collection (`AllDeleteOrphan`), NHibernate may re-save it by cascade; not fabricated.

## Operations and processes
- OP-DOM-15 AuditNote — ModifyNote moves references when the category changes; Delete removes the note (see [Operations and processes](../operations-processes.md))

## Business rules
- [DOM-BR-150](../business-rules.md#dom-br-150-note-create)

> **Note:** Statements marked with `*` were inferred from code structure, naming
> conventions, or contextual evidence where direct confirmation was not available
> in source artifacts. Statements marked with `**` could not be confirmed; treat
> as unknown until verified.

## Sources
- Domain/SAIF.Domain/Model/Claims/Bills/Notes/AuditNote.cs
