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

# SQL-194: Retrieve ErrorGroupEnvironment

This statement retrieves `ErrorGroupEnvironment` rows — unfiltered for the `EnvironmentsByGroup` property, or filtered by group code for `GetEnvironmentsForGroup` — called from `OnlineSupportRepository`. `OnlineSupportRepository` is registered against the Oracle provider (user `GEN`).

## Classification

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

## Parameters

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| `:groupLower` | Input | String | N/A | `group.ToLower()`, client-side — filters `ERROR_GROUP` (statement 2 only) |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [ERROR_GROUP_ENVIRONMENT](../database-tables.md#error_group_environment) | SELECT | `ID`, `ERROR_GROUP`, `ENVIRONMENT` |
| [ERROR_ENVIRONMENT](../database-tables.md#error_environment) | Read (lazy load, separate statement) | Lazy-loaded per distinct FK by `x.Environment.Description`/`EnvironmentName` in the in-memory `ForEach` (L47-48, L80-81) |
| [ERROR_GROUP_CODE](../database-tables.md#error_group_code) | Read (lazy load, separate statement) | Lazy-loaded by `x.Group.Description` in statement (1), L50 only |

## LINQ statement

Source: `Services/SAIF.Services/OnlineSupport/Repositories/OnlineSupportRepository.cs:38`, with a second fragment at line 74.

```csharp
// Services/SAIF.Services/OnlineSupport/Repositories/OnlineSupportRepository.cs:38
var data = _unitOfWork.GetRepository<ErrorGroupEnvironment>().Query().ToList();

// Services/SAIF.Services/OnlineSupport/Repositories/OnlineSupportRepository.cs:74
var data = _unitOfWork.GetRepository<ErrorGroupEnvironment>().Query().Where(ege => ege.Group.Code.ToLower() == group.ToLower()).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
-- (1) L38 — EnvironmentsByGroup
SELECT EGE.ID,
       EGE.ERROR_GROUP,
       EGE.ENVIRONMENT
FROM   ERROR_GROUP_ENVIRONMENT EGE

-- (2) L74 — GetEnvironmentsForGroup
SELECT EGE.ID, EGE.ERROR_GROUP, EGE.ENVIRONMENT
FROM   ERROR_GROUP_ENVIRONMENT EGE
WHERE  LOWER(EGE.ERROR_GROUP) = :groupLower
```

Translation notes:
- `x.Environment.Id` / `x.Group.Code` are served from FK columns without loading the proxy; other properties trigger lazy loads.
- In statement (2), `ege.Group.Code.ToLower()` reads the identifier of `ErrorGroupCode` → `LOWER(EGE.ERROR_GROUP)`; `ERROR_GROUP_CODE` is not joined (and statement (2)'s `ForEach` does not touch `x.Group`).

## Operations and processes
- OnlineSupportRepository.EnvironmentsByGroup (property) — see [Operations and processes](../operations-processes.md)
- OnlineSupportRepository.GetEnvironmentsForGroup — see [Operations and processes](../operations-processes.md)

## Sources
- `Services/SAIF.Services/OnlineSupport/Repositories/OnlineSupportRepository.cs (L38, L74)`
