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

# SQL-231: TaskQueryProvider.GetSource

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

## Classification

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

## Parameters

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| `code` | Input | string | N/A | Method argument of `TaskQueryProvider.GetSource` bound into the ORM expression; NHibernate generates the bind variable at runtime |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [TASK_SOURCE_CODE](../database-tables.md#task_source_code) | SELECT | Code, CODE_DESCR |

## LINQ statement

Source: `Data/SAIF.Data/Queries/Tasks/TaskQueryProvider.cs:29-30`.

```csharp
public TaskSource GetSource(string code)
{
    return Factory.GetRepository<TaskSource>().Query()
        .SingleOrDefault(x => x.Code.ToLower() == code.ToLower());
}
```

## 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
  TSC.Code,
  TSC.CODE_DESCR
FROM TASK_SOURCE_CODE TSC
WHERE LOWER(TSC.Code) = LOWER(:code)
-- SingleOrDefault: NHibernate expects at most one row
```

Translation notes:
- `TaskSourceMap` (`TaskMap.cs:83`) declares `Id(x => x.Code)` with no explicit `.Column(name)` call (line 88). With no conventions registered, FluentNHibernate's default column name is the property name `Code`. Oracle treats the unquoted identifier as `CODE`.
- `code.ToLower()` may be evaluated client-side and bound pre-lowered; the result is the same either way.

## Operations and processes

- [Other query providers](../operations/other-query-providers.md)

## Business rules

- [SD-BR-091 Task codes compared case-insensitively](../business-rules.md#sd-br-091-task-codes-compared-case-insensitively)

## Sources
- `Data/SAIF.Data/Queries/Tasks/TaskQueryProvider.cs:29`
