Skip to content

SQL-177: Retrieve Employee via GetTerminatedAuthorities

This statement joins terminated (non-active) Employee rows to their claim-authority limit records, joining the business-process and business-function code tables for display text, and orders the result by employee, process, function, and purpose. The Employee entity's ClassMap lives in the external SAIF.Framework.Data.NHibernate package; Legends resolved only the table name (ADP_EMPLOYEE), so the Employee columns used here are shown as C# property names.

Classification

Field Value
SQL ID SQL-177
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 GetTerminatedAuthorities

Parameters

None (literal 'A').

Tables

Table Access Columns used
ADP_EMPLOYEE** SELECT Id (join), UserId (order), EmployeeStatusCode (filter), full entity (C# property names — column mapping unresolved)
CL_CLAIM_EMP_BUS_FUNC_LIMIT SELECT, JOIN all mapped columns; EMPLOYEE_EMPLID (join)
CL_CLAIM_BUS_PROCESS_CODE JOIN Code (join), CODE_DESCR (order)
CL_CLAIM_BUS_FUNCTION_CODE JOIN Code (join), CODE_DESCR (order)

LINQ statement

Source: Services/SAIF.Services/Claims/Authority/ClaimAuthorityService.cs:353. Additional fragments at :354, :356.

// Services/SAIF.Services/Claims/Authority/ClaimAuthorityService.cs:353
var limits = _unitOfWork.GetRepository<EmployeeAuthorityLimit>().Query();

// Services/SAIF.Services/Claims/Authority/ClaimAuthorityService.cs:354
var emp = _unitOfWork.GetRepository<Employee>().Query();

// Services/SAIF.Services/Claims/Authority/ClaimAuthorityService.cs:356
var terminatedLimits = emp.Where(e => e.EmployeeStatusCode != "A")
    .Join(limits, e => e.Id, l => l.EmployeeId, (e, l) => new { employee = e, limits = l })
    .OrderBy(e => e.employee.UserId)
    .ThenBy(l => l.limits.BusinessProcess.Description)
    .ThenBy(l => l.limits.FunctionType.Description)
    .ThenBy(l => l.limits.PurposeType)
    .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.

-- Inferred from LINQ (NHibernate mapping translation); not concrete SQL
SELECT E.Id, E.UserId /* ...full Employee column list */,       -- unresolved mapping: Employee.*
       L.CL_CLM_EMP_BUS_FUN_LIM_SEQ_NUM, L.AUTHORIZED_BY_EMPLID, L.EMPLOYEE_EMPLID, L.EXP_DATE, L.MAX_AMOUNT,
       L.UPDATE_DATE, L.UPDATE_USER, L.UPDATE_NUM, L.CLAIM_AUTH_PURPOSE_CODE, L.CLAIM_BUS_PROCESS_CODE, L.CLAIM_BUS_FUNCTION_CODE
FROM   ADP_EMPLOYEE E
INNER JOIN CL_CLAIM_EMP_BUS_FUNC_LIMIT L    ON L.EMPLOYEE_EMPLID = E.Id          -- unresolved mapping: Employee.Id
INNER JOIN CL_CLAIM_BUS_PROCESS_CODE BP ON BP.Code = L.CLAIM_BUS_PROCESS_CODE
INNER JOIN CL_CLAIM_BUS_FUNCTION_CODE FT ON FT.Code = L.CLAIM_BUS_FUNCTION_CODE
WHERE  E.EmployeeStatusCode <> 'A'                                         -- unresolved mapping: Employee.EmployeeStatusCode
ORDER BY E.UserId, BP.CODE_DESCR, FT.CODE_DESCR, L.CLAIM_AUTH_PURPOSE_CODE;

Translation notes: - ** = unresolved column mapping (C# property names shown). Table name ADP_EMPLOYEE is from Legends documentation of SAIF.Framework.Data.NHibernate. - Two IQueryables (L353, L354) are combined by Join(...) into one statement materialized by .ToList() at L362. - BusinessProcess.Description / FunctionType.Description are non-identifier properties → joins to the code tables are required for ORDER BY (NHibernate emits implicit inner joins). - PurposeType uses CustomType<EmployeeAuthorityLimit.AuthorityPurposeTypes> (enum → numeric).

Operations and processes

Sources

  • Services/SAIF.Services/Claims/Authority/ClaimAuthorityService.cs (L354)