Skip to content

SQL-183: Retrieve Employee via GetApproverMailId

This statement retrieves a single Employee record by Id with NHibernate LINQ Single, called from SubpoenaPaymentService.GetApproverMailId to read the employee's UserId. 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.

Classification

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

Parameters

Parameter Direction Type Max length Description
:employeeId Input String N/A The manager id when approvedByEmployeeId == "OUTSIDECNCL", else the approver id (resolved client-side) — filters Employee.Id (unresolved mapping)

Tables

Table Access Columns used
ADP_EMPLOYEE** SELECT full entity; filter Id — C# property names, column mapping unresolved

LINQ statement

Source: Services/SAIF.Services/Legal/Subpoenas/SubpoenaPaymentService.cs:330

userId = _unitOfWork.GetRepository<Employee>()
    .Query()
    .Single(x => x.Id == employeeId).UserId;

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.

-- Inferred from LINQ (NHibernate mapping translation); not concrete SQL
SELECT E.Id, E.UserId, E.EmployeeStatusCode, E.FirstName, E.LastName, E.PreferredName,
       E.EmailAddress, E.Phone, E.Department, E.JobTitle /* , ...remaining EmployeeMap columns */
       -- unresolved mapping: Employee.* (C# property names; physical columns not resolvable)
FROM   ADP_EMPLOYEE E
WHERE  E.Id = :employeeId                          -- unresolved mapping: Employee.Id
-- NHibernate expects at most one row

Translation notes: - ** = unresolved column mapping (C# property names shown). Table name ADP_EMPLOYEE is resolved from Legends documentation of SAIF.Framework.Data.NHibernate. - SingleOrDefault/Single add no row limit; NHibernate throws if more than one row is returned. - Only executed when employeeId is not blank (L328).

Operations and processes

Sources

  • Services/SAIF.Services/Legal/Subpoenas/SubpoenaPaymentService.cs (L330)