---
title: "SQL-281: Retrieve PurchaseOrderComment via RetrievePurchaseOrderComments"
summary: Read operation against PurchaseOrderComment via NHibernate ORM.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-09-24
library: SAIF.Services
reference_type: package
---

# SQL-281: Retrieve PurchaseOrderComment via RetrievePurchaseOrderComments

This statement retrieves `PurchaseOrderComment` rows via NHibernate LINQ whose trimmed composite-key index is not empty, in `PurchaseOrderService.RetrievePurchaseOrderComments`, executed from `Services/SAIF.Services/Corporate/PurchaseOrderService.cs (L74)`.

## Classification

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

## Parameters

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| `:emptyString` | Input | string | N/A | `string.Empty` (`''`) — compared against `TRIM(L_INDEX)` |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [PURCHASEORDERCOMMENTS](../database-tables.md#purchaseordercomments) | SELECT | `L_INDEX`, `ATCHNBR`, `OBJECT` |

## LINQ statement

Source: `Services/SAIF.Services/Corporate/PurchaseOrderService.cs:74`

```csharp
// Services/SAIF.Services/Corporate/PurchaseOrderService.cs:74
return _unitOfWork.GetRepository<PurchaseOrderCommentModel>().Query().Where(x => x.Id.Trim() != string.Empty).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
  POC.L_INDEX,
  POC.ATCHNBR,
  POC.OBJECT
FROM PurchaseOrderComments POC
WHERE TRIM(POC.L_INDEX) <> :emptyString
```

Translation notes:
- `x.Id` is the first `CompositeId` key property (`PurchaseOrderCommentsMap.cs:13`, `L_INDEX`); `Trim()` → `TRIM(...)`.
- Oracle treats `''` as `NULL`, so `TRIM(L_INDEX) <> ''` evaluates to UNKNOWN for every row and the statement is expected to return no rows under the Oracle dialect. Inferred behavioural observation, not runtime-verified.

## Operations and processes
- PurchaseOrderService.RetrievePurchaseOrderComments — see [Operations and processes](../operations-processes.md)

## Sources
- `Services/SAIF.Services/Corporate/PurchaseOrderService.cs (L74)`
