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

# SQL-385: Delete MedicareBeneficiaryQuery via ProcessDeleteMedicareBeneficiarysForBatch

This statement deletes `MedicareBeneficiaryQuery` entities identified by their `MEDICARE_QUERY_SEQ_NUM` key from `MEDICARE_BENEFICIARY_QUERY`, executed via `IUnitOfWork.GetRepository<T>().Delete(...)` from `Services/SAIF.Services/Claims/Medicare/MedicareService.cs (L133)` in `MedicareService.ProcessDeleteMedicareBeneficiarysForBatch`. The SQL below is inferred from this repository call and the NHibernate `MedicareBeneficiaryQueryMap` mapping — it is not literal SQL present in source.

## Classification

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

## Parameters

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

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [MEDICARE_BENEFICIARY_QUERY](../database-tables.md#medicare_beneficiary_query) | DELETE | `MEDICARE_QUERY_SEQ_NUM` |

## LINQ statement

Source: `Services/SAIF.Services/Claims/Medicare/MedicareService.cs:133`. The repository is obtained at line 128.

```csharp
// Services/SAIF.Services/Claims/Medicare/MedicareService.cs:128
var repository = _unitOfWork.GetRepository<MedicareBeneficiaryQuery>();

// Services/SAIF.Services/Claims/Medicare/MedicareService.cs:133
recordsToDelete.ForEach(repository.Delete);
```

## 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 MEDICARE_BENEFICIARY_QUERY
WHERE MEDICARE_QUERY_SEQ_NUM = :Id
```

Translation notes:

- `recordsToDelete.ForEach(repository.Delete)` issues one DELETE per record from `_queryProvider.GetBeneficiaries(...)` (line 130).

## Operations and processes
- MedicareService.ProcessDeleteMedicareBeneficiarysForBatch — see [Operations and processes](../operations-processes.md)

## Sources
- `Services/SAIF.Services/Claims/Medicare/MedicareService.cs (L133)`
