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

# SQL-174: Retrieve Employee via IsActiveEmployeeUserId

This statement performs an existence check against `ADP_EMPLOYEE` to determine whether a given user ID belongs to an active employee. The `Employee` entity's `ClassMap` lives in the external `SAIF.Framework.Data.NHibernate` package; Legends resolved only the table name (`ADP_EMPLOYEE`) and the `RPT_MGR_EMPLID` self-reference, so the columns used here are shown as C# property names.

## Classification

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

## Parameters

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| `:userIdUpper` | Input | string | N/A | `= userId.ToUpper()`, client-side → column UserId (unresolved) |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [ADP_EMPLOYEE](../database-tables.md#adp_employee)** | SELECT (existence probe) | UserId, EmployeeStatusCode (C# property names — column mapping unresolved) |

## LINQ statement

Source: `Services/SAIF.Services/Imaging/AutoImportHelperService.cs:261`

```csharp
return
    _unitOfWork.GetRepository<Employee>()
        .Query()
        .Any(x => x.UserId.ToUpper() == userId.ToUpper() && x.EmployeeStatusCode == "A");
```

## 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 * FROM (
    SELECT 1
    FROM   ADP_EMPLOYEE E
    WHERE  UPPER(E.UserId) = :userIdUpper            -- unresolved mapping: Employee.UserId
      AND  E.EmployeeStatusCode = 'A'                -- unresolved mapping: Employee.EmployeeStatusCode
) WHERE ROWNUM <= 1;
```

Translation notes:
- ** = unresolved column mapping (C# property names shown). Table name `ADP_EMPLOYEE` is from Legends documentation of `SAIF.Framework.Data.NHibernate`; no `ClassMap<Employee>` exists in this repo.
- `Any(...)` → existence probe (`SELECT 1 ... ROWNUM <= 1`); returns bool.

## Operations and processes
- AutoImportHelperService.IsActiveEmployeeUserId — see [Operations and processes](../operations-processes.md)

## Sources
- `Services/SAIF.Services/Imaging/AutoImportHelperService.cs (L262)`
