---
title: "SQL-006: AuditNoteQueryProvider.GetAuditNotesForBill"
summary: Read operation for `AuditNoteQueryProvider.GetAuditNotesForBill`
status: draft
owner: SAIF.Core documentation team
last_reviewed: 2026-09-24
library: SAIF.Data
reference_type: package
---

# SQL-006: AuditNoteQueryProvider.GetAuditNotesForBill

This statement is a read operation invoked through ORM (NHibernate LINQ). Executed by `AuditNoteQueryProvider.GetAuditNotesForBill`.

## Classification

| Field | Value |
| --- | --- |
| **SQL ID** | SQL-006 |
| **Operation type** | Read |
| **Execution method** | ORM (NHibernate LINQ) |
| **Database** | Oracle* |
| **Schema** | [unqualified]** |
| **Command type** | N/A (ORM-generated) |
| **Business object** | `AuditNoteQueryProvider` |
| **Criteria property** | N/A — ORM |
| **Lifecycle method** | `GetAuditNotesForBill` |

## Parameters

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| `billId` | Input | long | N/A | Method argument of `AuditNoteQueryProvider.GetAuditNotesForBill` bound into the ORM expression; NHibernate generates the bind variable at runtime |
| `includeInactive` | Input | bool | N/A | Method argument of `AuditNoteQueryProvider.GetAuditNotesForBill` bound into the ORM expression; NHibernate generates the bind variable at runtime |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [CBP_NOTE](../database-tables.md#cbp_note) | SELECT | CBP_NOTE_SEQ_NUM, UPDATE_NUM, ACTIVE_FLAG, CREATE_DATE, CREATE_USER, UPDATE_DATE, UPDATE_USER, NOTE_TXT, CLAIM_ID, NOTE_TYPE_CODE, NOTE_CATEGORY_CODE, BILL_ID |

## LINQ statement

Source: `Data/SAIF.Data/Queries/Claims/AuditNoteQueryProvider.cs:32`. The repository is a class field initialised from `Factory.GetRepository<CbpNote>().Query()` at `Data/SAIF.Data/Queries/Claims/AuditNoteQueryProvider.cs:14`.

```csharp
return repository.Where(x => x.Bill.Id == billId
     && (x.IsActive || x.IsActive != includeInactive)).ToList();
```

## 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
SELECT
  CN.CBP_NOTE_SEQ_NUM,
  CN.UPDATE_NUM,
  CN.ACTIVE_FLAG,
  CN.CREATE_DATE,
  CN.CREATE_USER,
  CN.UPDATE_DATE,
  CN.UPDATE_USER,
  CN.NOTE_TXT,
  CN.CLAIM_ID,
  CN.NOTE_TYPE_CODE,
  CN.NOTE_CATEGORY_CODE,
  CN.BILL_ID
FROM CBP_NOTE CN
WHERE CN.BILL_ID = :billId
  AND (CN.ACTIVE_FLAG = 'Y' OR CN.ACTIVE_FLAG <> :includeInactive)
```

Translation notes:
- `x.Bill.Id` is the identifier of `References(Bill).Column("BILL_ID")` at `CbpNoteMap.cs`, so it resolves to `CN.BILL_ID` with no join; `CBP_BILL` is not accessed as a separate table.

## Operations and processes

- [Audit note concurrency check](../operations/audit-note-concurrency-check.md)


## Sources
- `Data/SAIF.Data/Queries/Claims/AuditNoteQueryProvider.cs:32`
