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

# SQL-180: Retrieve Employee via ValidateMailId

This statement checks whether an `Employee` record exists with NHibernate LINQ `Any`, called from `SendPendRequestValidator.ValidateMailId`. The `Employee` entity's `ClassMap` lives in the external `SAIF.Framework.Data.NHibernate` package; the backing table resolves to `ADP_EMPLOYEE`, but its column mappings are unresolved beyond the `RPT_MGR_EMPLID` self-reference, so the inferred SQL below shows `UserId` as a C# property name.

## Classification

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

## Parameters

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| `:sendToMailIdUpper` | Input | String | N/A | `request.SendtoMailId.ToUpper()` — filters `Employee.UserId` (unresolved mapping) |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| ADP_EMPLOYEE** | SELECT | `UserId` — C# property name, column mapping unresolved |

## LINQ statement

Source: `Services/SAIF.Services/Claims/Bills/Validators/SendPendRequestValidator.cs:71`

```csharp
return factory.GetRepository<Employee>().Query().Any(x => x.UserId == request.SendtoMailId.ToUpper());
```

## 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  E.UserId = :sendToMailIdUpper             -- unresolved mapping: Employee.UserId
) WHERE ROWNUM <= 1;
```

Translation notes:
- `**` = unresolved column mapping (C# property names shown). Table name `ADP_EMPLOYEE` is resolved from Legends documentation of `SAIF.Framework.Data.NHibernate`.
- Repository obtained from `IRepositoryFactory`; still NHibernate LINQ.
- `Any` translates to an existence probe wrapped with `ROWNUM <= 1`.

## Operations and processes
- SendPendRequestValidator.ValidateMailId — see [Operations and processes](../operations-processes.md)

## Sources
- `Services/SAIF.Services/Claims/Bills/Validators/SendPendRequestValidator.cs (L71)`
