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

# SQL-377: Delete EbillInvoice via ProcessInvoiceFile

This statement deletes the `EbillInvoice` entity identified by its identifier (`EBILL_INVOICE_SEQ_NUM`) via `IUnitOfWork.GetRepository<T>().Delete(entity)`, invoked from `EBillingService.ProcessInvoiceFile` (`Services/SAIF.Services/Claims/EBilling/EBillingService.cs:1173`). Because the map declares a `Version` column, the deletion also carries an optimistic-concurrency check on `UPDATE_NUM`. The SQL below is inferred from this repository call and the `EbillInvoice` NHibernate mapping — it is not literal SQL present in source.

## Classification

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

## Parameters

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| `:Id` | Input | long | N/A | Identifier of the EbillInvoice being deleted (`EBILL_INVOICE_SEQ_NUM`) |
| `:oldVersion` | Input | int | N/A | Current `UPDATE_NUM` value (optimistic-concurrency check) |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [EBILL_INVOICE](../database-tables.md#ebill_invoice) | DELETE | `EBILL_INVOICE_SEQ_NUM`, `UPDATE_NUM` |

## LINQ statement

Source: `Services/SAIF.Services/Claims/EBilling/EBillingService.cs:1173`

```csharp
// Services/SAIF.Services/Claims/EBilling/EBillingService.cs:1173
_unitOfWork.GetRepository<EbillInvoice>().Delete(oldInvoice);
```

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

Translation notes:

- `Version(x => x.UpdateNumber).Column("UPDATE_NUM")` adds the old-version predicate to the DELETE.
- `HasMany(Bills)` and `HasMany(Errors)` (key `EBILL_INVOICE_SEQ_NUM`) are `Cascade.AllDeleteOrphan().Not.OptimisticLock().Inverse()` (lines 24-32) - deleting the invoice cascades deletes to `EBILL_INVOICE_BILL` / `EBILL_INVOICE_ERROR` children still associated; those child statements are not fabricated (the caller also deletes them explicitly - SQL-378/SQL-379).
- Entity obtained from `_eBillingQueryProvider.InvoiceQueries.GetInvoice(...)` (line 1147).

## Operations and processes
- EbillingService.ProcessInvoiceFile — see [Operations and processes](../operations-processes.md)

## Sources
- `Services/SAIF.Services/Claims/EBilling/EBillingService.cs (L1173)`
