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

# SQL-319: Retrieve Task via GetClaimBillQueueRemainingCount

This statement counts `TASK` records assigned to the `{CBPAPP}` system user that are not marked deleted, used by `BillEntryService.GetClaimBillQueueRemainingCount` to determine the remaining bill queue size. The SQL is inferred from the NHibernate LINQ `Count` query and the `TaskMap` mapping shown below — it is not literal SQL text in the source code.

## Classification

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

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [TASK](../database-tables.md#task) | SELECT | `TASK_USER`, `DELETE_FLAG` |

## LINQ statement

Source: `Services/SAIF.Services/Claims/Bills/BillEntryService.cs:223`

```csharp
// Services/SAIF.Services/Claims/Bills/BillEntryService.cs:223
return unitOfWork.GetRepository<Task>().Query().Count(x => x.TaskUser == "{CBPAPP}" && x.IsDeleted == false);
```

## 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
  COUNT(*)
FROM TASK T
WHERE T.TASK_USER = '{CBPAPP}'
  AND T.DELETE_FLAG = 'N'
```

Translation notes:

- `Count(predicate)` -> `SELECT COUNT(*)`; `IsDeleted == false` -> `'N'` (`YesNoType`).
- `Task` resolves to `SAIF.Data.Model.Tasks.Task` (`using SAIF.Data.Model.Tasks;` in `BillEntryService.cs`).

## Operations and processes
- BillEntryService.GetClaimBillQueueRemainingCount — see [Operations and processes](../operations-processes.md)

## Sources
- `Services/SAIF.Services/Claims/Bills/BillEntryService.cs (L223)`
