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

# SQL-331: Retrieve TaskGroup

This statement retrieves `CLAIM_TASK_GROUP_CODE` records for `TaskService`, in two shapes: `GetTaskGroups` returns the full list, and `CreateTaskStateless`/`CreateTask`/`UpdateTask`/`ReassignTasks` look up a single task group by code (skipped when the code is `NULL`). The SQL is inferred from the NHibernate LINQ queries and the `TaskGroup` class map shown below — it is not literal SQL text in the source code.

## Classification

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

## Parameters

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| `:Code` | Input | string | N/A | `taskEdit.TaskGroup.Code` (line 528), `task.TaskGroup.Code` (line 614), `taskCopy.TaskGroup.Code` (line 690); at line 863 the bound value is the method argument `newGroup`. |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [CLAIM_TASK_GROUP_CODE](../database-tables.md#claim_task_group_code) | SELECT | `Code`, `UPDATE_NUM`, `CODE_DESCR`, `UPDATE_DATE`, `UPDATE_USER` |

## LINQ statement

Source: `Services/SAIF.Services/Claims/Tasks/TaskService.cs:146`

```csharp
// Services/SAIF.Services/Claims/Tasks/TaskService.cs:146
return Mapper.Map<TaskGroup[]>(_unitOfWork.GetRepository<TaskData.TaskGroup>().Query());

// Services/SAIF.Services/Claims/Tasks/TaskService.cs:528
newTask.TaskGroup = taskEdit.TaskGroup.Code == "NULL" ? null : _unitOfWork.GetRepository<TaskData.TaskGroup>().Query().SingleOrDefault(x => x.Code == taskEdit.TaskGroup.Code);

// Services/SAIF.Services/Claims/Tasks/TaskService.cs:614
taskData.TaskGroup = task.TaskGroup.Code == "NULL" ? null : _unitOfWork.GetRepository<TaskData.TaskGroup>().Query().SingleOrDefault(x => x.Code == task.TaskGroup.Code);

// Services/SAIF.Services/Claims/Tasks/TaskService.cs:690
taskData.TaskGroup = task.TaskGroup.Code == "NULL" ? null : _unitOfWork.GetRepository<TaskData.TaskGroup>().Query().SingleOrDefault(x => x.Code == taskCopy.TaskGroup.Code);

// Services/SAIF.Services/Claims/Tasks/TaskService.cs:863
: _unitOfWork.GetRepository<TaskData.TaskGroup>().Query().SingleOrDefault(x => x.Code == newGroup);
```

## 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
-- TaskService.GetTaskGroups (line 146): enumerated by Mapper.Map
SELECT
  CTGC.Code,
  CTGC.UPDATE_NUM,
  CTGC.CODE_DESCR,
  CTGC.UPDATE_DATE,
  CTGC.UPDATE_USER
FROM CLAIM_TASK_GROUP_CODE CTGC

-- TaskService.CreateTaskStateless (528), CreateTask (614), UpdateTask (690), ReassignTasks (863)
SELECT
  CTGC.Code,
  CTGC.UPDATE_NUM,
  CTGC.CODE_DESCR,
  CTGC.UPDATE_DATE,
  CTGC.UPDATE_USER
FROM CLAIM_TASK_GROUP_CODE CTGC
WHERE CTGC.Code = :Code
-- NHibernate expects at most one row
```

Translation notes:

- Two shapes share this SQL ID. The single-row lookups are skipped client-side when the code is `"NULL"` (ternaries at 528/614/690/861).

## Operations and processes
- TaskService.CreateTask — see [Operations and processes](../operations-processes.md)
- TaskService.CreateTaskStateless — see [Operations and processes](../operations-processes.md)
- TaskService.GetTaskGroups — see [Operations and processes](../operations-processes.md)
- TaskService.ReassignTasks — see [Operations and processes](../operations-processes.md)
- TaskService.UpdateTask — see [Operations and processes](../operations-processes.md)

## Business rules
- [SVC-BR-CLM-100 Claim must exist](../business-rules.md#svc-br-clm-100-claim-must-exist)

## Sources
- `Services/SAIF.Services/Claims/Tasks/TaskService.cs (L146, L528, L614, L690, L863)`
