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

# SQL-326: Retrieve TaskCategory via CreateTask

This statement retrieves the `TASK_CATEGORY_CODE` record with code `COLL`, used by `CollectionsService.CreateTask` to default a new collections task's category. The SQL is inferred from the NHibernate LINQ query and the `TaskCategory` class map shown below — it is not literal SQL text in the source code.

## Classification

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

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [TASK_CATEGORY_CODE](../database-tables.md#task_category_code) | SELECT | `Code`, `CODE_DESCR`, `NOTEPAD_REQUIRED_FLAG`, `DEFAULT_ACTION_CODE`, `DEFAULT_PRIORITY_CODE`, `TASK_SOURCE_CODE` |

## LINQ statement

Source: `Services/SAIF.Services/Collections/CollectionsService.cs:1387`

```csharp
// Services/SAIF.Services/Collections/CollectionsService.cs:1387
taskData.TaskCategory = UnitOfWork.GetRepository<TaskDataModel.TaskCategory>().Query().SingleOrDefault(x => x.Code == "COLL");
```

## 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
  TCC.Code,
  TCC.CODE_DESCR,
  TCC.NOTEPAD_REQUIRED_FLAG,
  TCC.DEFAULT_ACTION_CODE,
  TCC.DEFAULT_PRIORITY_CODE,
  TCC.TASK_SOURCE_CODE
FROM TASK_CATEGORY_CODE TCC
WHERE TCC.Code = 'COLL'
-- NHibernate expects at most one row
```

Translation notes:

- `SingleOrDefault` -> no row limit; NHibernate expects at most one row.
- `DefaultAction`, `DefaultPriority`, `TaskSource` references contribute FK columns only; no join.

## Operations and processes
- CollectionsService.CreateTask — see [Operations and processes](../operations-processes.md)

## Sources
- `Services/SAIF.Services/Collections/CollectionsService.cs (L1387)`
